file-identify 0.5.0

File type identification (tags from names, extensions, shebangs and content) - a faithful Rust port of Python identify, as used by pre-commit
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! identify's `interpreters` module: the shebang interpreter table.

use crate::tags::TagSet;

pub use crate::generated::INTERPRETERS;

/// Tags for an exact interpreter name of [`INTERPRETERS`] (empty if
/// unknown).
///
/// [`tags_from_interpreter`](crate::tags_from_interpreter) implements
/// identify's full rules (path stripping and version fallback such as
/// `python3.12` → `python3`).
#[must_use]
pub fn get_interpreter_tags(interpreter: &str) -> TagSet {
    INTERPRETERS.get(interpreter).unwrap_or_default()
}