Skip to content

Commit

Permalink
small tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
bnkc committed Apr 10, 2024
1 parent 12e472e commit 7e744bc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
33 changes: 12 additions & 21 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,18 @@ fn construct_config(opts: Opts) -> Result<Config> {
let base_directory = &opts.base_directory;
let dep_type = opts.dep_type;
let dep_files = get_dependency_spec_files(base_directory)?;
let dep_spec_file: PathBuf;
match dep_type {
DepType::Pip => {
dep_spec_file = dep_files
.iter()
.find(|file| file.ends_with("requirements.txt"))
.ok_or_else(|| {
anyhow!("Could not find `requirements.txt` in the provided directory.")
})?
.to_owned();
}
DepType::Poetry => {
dep_spec_file = dep_files
.iter()
.find(|file| file.ends_with("pyproject.toml"))
.ok_or_else(|| {
anyhow!("Could not find `pyproject.toml` in the provided directory.")
})?
.to_owned();
}
}
let dep_spec_file = match opts.dep_type {
DepType::Pip => dep_files
.iter()
.find(|file| file.ends_with("requirements.txt"))
.ok_or_else(|| anyhow!("Could not find `requirements.txt` in the provided directory."))?
.to_owned(),
DepType::Poetry => dep_files
.iter()
.find(|file| file.ends_with("pyproject.toml"))
.ok_or_else(|| anyhow!("Could not find `pyproject.toml` in the provided directory."))?
.to_owned(),
};

let ignore_hidden = opts.ignore_hidden;
let output = opts.output;
Expand Down
4 changes: 2 additions & 2 deletions src/project_assets/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl DependencyCollector {
);
}
}
// Ignore other types for now...

_ => (),
}
}
Expand All @@ -114,7 +114,6 @@ fn get_pip_dependencies(dep_spec_file: &Path) -> Result<HashSet<Dependency>> {
);
}
}
println!("Found {:#?} dependencies", dependencies);

Ok(dependencies)
}
Expand Down Expand Up @@ -152,6 +151,7 @@ mod tests {
use std::io::Write;
use std::path::PathBuf;
use tempfile::tempdir;
// Requirements.txt still need tested

/// Helper function to create a temporary pyproject.toml file.
fn create_pyproject_toml_file(dir: &tempfile::TempDir, content: &str) -> PathBuf {
Expand Down

0 comments on commit 7e744bc

Please sign in to comment.