python_check_updates/parsers/
mod.rs

1pub mod conda;
2pub mod lockfiles;
3pub mod pyproject;
4pub mod requirements;
5
6pub use conda::CondaParser;
7pub use lockfiles::LockfileParser;
8pub use pyproject::PyProjectParser;
9pub use requirements::RequirementsParser;
10
11use crate::version::VersionSpec;
12use std::path::PathBuf;
13
14/// A dependency as parsed from a file
15#[derive(Debug, Clone)]
16pub struct Dependency {
17    /// Package name (normalized to lowercase)
18    pub name: String,
19    /// Version specification as parsed
20    pub version_spec: VersionSpec,
21    /// Source file this dependency was found in
22    pub source_file: PathBuf,
23    /// Line number in the source file (1-indexed)
24    pub line_number: usize,
25    /// Original line text (for updating)
26    pub original_line: String,
27}
28
29/// Trait for dependency file parsers
30pub trait DependencyParser {
31    /// Parse a file and return all dependencies found
32    fn parse(&self, path: &PathBuf) -> anyhow::Result<Vec<Dependency>>;
33
34    /// Check if this parser can handle the given file
35    fn can_parse(&self, path: &PathBuf) -> bool;
36}