From 12d07e873ea21263fbacb5e0193d38893ceff846 Mon Sep 17 00:00:00 2001 From: Qrius Date: Wed, 5 Mar 2025 11:10:07 +0100 Subject: Seemingly up to scratch now --- skaldpress_main.rs | 324 --------------------------------------------- src/skaldpress/main.py | 81 +++++++++--- src/smp/builtins.py | 13 ++ src/smp/macro_processor.py | 7 +- 4 files changed, 78 insertions(+), 347 deletions(-) delete mode 100644 skaldpress_main.rs diff --git a/skaldpress_main.rs b/skaldpress_main.rs deleted file mode 100644 index 5e6530c..0000000 --- a/skaldpress_main.rs +++ /dev/null @@ -1,324 +0,0 @@ -use skaldpress::macro_processor::error::SMPError; -use skaldpress::macro_processor::macro_processor::{MacroProcessorWarning, MacroType}; -use skaldpress::skaldpress::filelists::{make_filelist, FileList, FileListFileTargetAction}; -use skaldpress::skaldpress::parseopts::{parseopts, Opts}; -use std::cmp::Ordering; -use std::collections::HashMap; -use std::collections::VecDeque; -use std::fs; -use std::path::Path; -use std::time::Instant; - -use skaldpress::macro_processor::MacroProcessor; -use skaldpress::skaldpress::error::SkaldpressError; -use skaldpress::skaldpress::error::{ - SP_COMPILE_FILE_EXTENSION_ERROR_2, SP_COMPILE_FILE_MACRO_PROCESS_ERROR, - SP_COMPILE_FILE_TEMPLATE_READ_ERROR, SP_COMPILE_TEMPLATE_MACRO_PROCESS_ERROR, - SP_GEN_DEST_STRIP_PREFIX_ERROR, -}; -use skaldpress::skaldpress::metadata_parser::extract_parse_yaml_metadata; -use skaldpress::skaldpress::metadata_parser::YamlValue; - -/// Convenience function for doing cmp on a metadata key of two arbitrary indexes -/// This takes a macro_processor as input, so that it can emit warnings if the ordering failed in -/// any way. -fn order_index_by_cached_data( - smp: &mut MacroProcessor, - key: &str, - a: &usize, - b: &usize, -) -> Ordering { - let compiled_files: &Vec; - unsafe { - compiled_files = COMPILED_FILES.as_ref(); - } - if *a >= compiled_files.len() { - smp.warnings.push(MacroProcessorWarning::new(format!( - "\"a\" is not a cached file {} >= {}", - *a, - compiled_files.len() - ))); - return Ordering::Equal; - } - if *b >= compiled_files.len() { - smp.warnings.push(MacroProcessorWarning::new(format!( - "\"b\" is not a cached file {} >= {}", - *b, - compiled_files.len() - ))); - return Ordering::Equal; - } - let Some(a) = &compiled_files[*a].metadata.get(key) else { - smp.warnings.push(MacroProcessorWarning::new(format!( - "Key {:?} not found for ordering data in {:?}", - key, compiled_files[*a].source_path - ))); - return Ordering::Equal; - }; - let Some(b) = &compiled_files[*b].metadata.get(key) else { - smp.warnings.push(MacroProcessorWarning::new(format!( - "Key {:?} not found for ordering data in {:?}", - key, compiled_files[*b].source_path - ))); - return Ordering::Equal; - }; - a.cmp(b) -} - -/// SMP Macro for getting all files with specific tag, this is only _really_ effective the second run -/// -/// Usage in files: -/// all_tagged_by(,