Skip to content

Commit

Permalink
WIP: custom seperator for serval capture
Browse files Browse the repository at this point in the history
  • Loading branch information
wsyxbcl committed Dec 18, 2024
1 parent 4360532 commit 43e7725
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
16 changes: 12 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use tags::{
extract_resources, get_classifications, get_temporal_independence, init_xmp, write_taglist,
};
use utils::{
absolute_path, copy_xmp, deployments_align, deployments_rename, resources_align,
ExtractFilterType, ResourceType, TagType,
absolute_path, copy_xmp, deployments_align, deployments_rename, get_path_seperator,
resources_align, ExtractFilterType, ResourceType, TagType,
};

fn main() -> anyhow::Result<()> {
Expand Down Expand Up @@ -100,8 +100,12 @@ fn main() -> anyhow::Result<()> {
tag_type,
)?;
}
Commands::Capture { csv_path, output } => {
get_temporal_independence(absolute_path(csv_path)?, output)?;
Commands::Capture {
csv_path,
output,
sep,
} => {
get_temporal_independence(absolute_path(csv_path)?, output, &sep)?;
}
Commands::Extract {
csv_path,
Expand Down Expand Up @@ -226,6 +230,10 @@ enum Commands {
default_value = "./serval_output/serval_capture"
)]
output: PathBuf,

/// Path seperator for determining the deployment
#[arg(long, default_value = get_path_seperator())]
sep: String,
},
/// Extract and copy resources by filtering target values (based on tags.csv)
#[command(arg_required_else_help = true)]
Expand Down
11 changes: 8 additions & 3 deletions src/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub fn write_taglist(
tag_type: TagType,
) -> anyhow::Result<()> {
// Write taglist to the dummy image metadata (digiKam.TagsList)
// TODO: adapt Adobe hierarchicalSubject
let mut f = XmpFile::new()?;
let tag_df = CsvReadOptions::default()
.with_infer_schema_length(Some(0))
Expand Down Expand Up @@ -508,7 +509,7 @@ pub fn get_classifications(
);

if independent {
get_temporal_independence(tags_csv_path, output_dir)?;
get_temporal_independence(tags_csv_path, output_dir, get_path_seperator())?;
}
Ok(())
}
Expand Down Expand Up @@ -767,7 +768,11 @@ pub fn extract_resources(
Ok(())
}

pub fn get_temporal_independence(csv_path: PathBuf, output_dir: PathBuf) -> anyhow::Result<()> {
pub fn get_temporal_independence(
csv_path: PathBuf,
output_dir: PathBuf,
sep: &str,
) -> anyhow::Result<()> {
// Temporal independence analysis

let mut df = match CsvReadOptions::default()
Expand Down Expand Up @@ -867,7 +872,7 @@ pub fn get_temporal_independence(csv_path: PathBuf, output_dir: PathBuf) -> anyh
col("path"),
col("path")
.str()
.split(lit(get_path_seperator()))
.split(lit(sep))
.list()
.get(lit(num_option - deploy_path_index), false)
.alias("deployment"),
Expand Down

0 comments on commit 43e7725

Please sign in to comment.