Use OS dependent path separator when constructing paths in tree writer

korrat
Oct 26, 2022, 7:01 PM
2NYDNXH7PDF7ZYAGJXWYOUJKGDT4HVWZRU73SA4CSFLVIIK2CIDAC

Dependencies

  • [2] 2JBFREZG enable additional warnings
  • [3] SJ6AFVZL remove const configuration in favor of runtime config
  • [4] MG46NYAC enable deserialization of configuration for common utilities
  • [5] D6UTHZA4 add a simple writer for saving a set of directives to a tree of files
  • [*] UESS5YZE migrate dependencies into workspace manifest
  • [*] I2P2FTLE add basic parser for german decimals

Change contents

  • edit in common/beancount-tree-writer/src/lib.rs at line 7
    [2.16504]
    [3.24]
    use std::path;
  • edit in common/beancount-tree-writer/src/lib.rs at line 15
    [3.364]
    [3.364]
    use miette::Diagnostic;
  • replacement in common/beancount-tree-writer/src/lib.rs at line 28
    [3.771][3.771:795](),[3.795][3.39:69]()
    #[derive(Debug, Snafu)]
    pub struct Error(InnerError);
    [3.63]
    [3.1225]
    #[derive(Debug, Diagnostic, Snafu)]
    #[snafu(display("encountered multiple errors while writing tree of accounts"))]
    pub struct Error {
    #[related]
    errors: Vec<ErrorKind>,
    }
  • replacement in common/beancount-tree-writer/src/lib.rs at line 73
    [3.2049][3.639:696]()
    todo!("convert errors to summarized report")
    [3.2049]
    [3.2225]
    Err(Error { errors })
  • replacement in common/beancount-tree-writer/src/lib.rs at line 84
    [3.2368][3.771:805]()
    ) -> Result<(), InnerError> {
    [3.2368]
    [3.2397]
    ) -> Result<(), ErrorKind> {
  • replacement in common/beancount-tree-writer/src/lib.rs at line 102
    [3.2877][3.2877:2928]()
    File::create(file_path).map_err(<_>::into)
    [3.2877]
    [3.2928]
    File::create(file_path)
  • edit in common/beancount-tree-writer/src/lib.rs at line 126
    [3.3383]
    [3.3383]
    let separator = path::MAIN_SEPARATOR;
  • replacement in common/beancount-tree-writer/src/lib.rs at line 129
    [3.3424][3.3424:3565]()
    let additional = AsRef::<str>::as_ref(&account).len() + 4 + 2 + 5 + 3; // account name + year + month + extension + extra separators
    [3.3424]
    [3.3565]
    let additional = account.len() + 4 + 2 + 5 + 3; // account name + year + month + extension + extra separators
  • replacement in common/beancount-tree-writer/src/lib.rs at line 134
    [3.3640][3.3640:3714]()
    .for_each(|component| write!(path, "/{component}").unwrap());
    [3.3640]
    [3.3714]
    .for_each(|segment| write!(path, "{separator}{segment}").unwrap());
  • replacement in common/beancount-tree-writer/src/lib.rs at line 136
    [3.3715][3.3715:3773]()
    write!(path, "/{year}/{month:02}.bean").unwrap();
    [3.3715]
    [3.3773]
    write!(path, "{separator}{year}{separator}{month:02}.bean").unwrap();
  • replacement in common/beancount-tree-writer/src/lib.rs at line 143
    [3.3849][3.1140:1169]()
    type Error = InnerError;
    [3.3849]
    [3.3873]
    type Error = ErrorKind;
  • replacement in common/beancount-tree-writer/src/lib.rs at line 166
    [3.1173][3.1173:1215]()
    #[derive(Debug, Snafu)]
    enum InnerError {
    [3.1173]
    [3.1215]
    #[derive(Debug, Diagnostic, Snafu)]
    enum ErrorKind {
  • edit in common/beancount-tree-writer/src/lib.rs at line 173
    [3.1395]
    [3.1395]
  • edit in common/beancount-tree-writer/Cargo.toml at line 21
    [7.697]
    [7.697]
    miette.workspace = true
  • edit in Cargo.lock at line 198
    [3.5865]
    [3.5865]
    "miette",