Skip to content

Commit a71bb3e

Browse files
committed
factor concat function
1 parent 30c94c6 commit a71bb3e

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn extract_regex(re: &Regex, x: String) -> (String, String) {
5757
(
5858
x.replace(
5959
&caps["frames"],
60-
String::from_utf8(vec![b'*'; caps["frames"].len()])
60+
String::from_utf8(vec![b'#'; caps["frames"].len()])
6161
.unwrap()
6262
.as_str(),
6363
),
@@ -79,7 +79,7 @@ fn test_regex_simple() {
7979
let re = get_regex();
8080
let source: String = "RenderPass_Beauty_1_00000.exr".to_string();
8181
let expected: (String, String) = (
82-
"RenderPass_Beauty_1_*****.exr".to_string(),
82+
"RenderPass_Beauty_1_#####.exr".to_string(),
8383
"00000".to_string(),
8484
);
8585
assert_eq!(expected, extract_regex(&re, source))
@@ -124,7 +124,7 @@ fn test_parse_string() {
124124
let vec_toto: Vec<String> = vec!["001".to_string(), "002".to_string(), "003".to_string()];
125125
let vec_foo: Vec<String> = vec!["None".to_string()];
126126
let expected: HashMap<String, Vec<String>> = HashMap::from([
127-
("toto.***.tiff".to_string(), vec_toto),
127+
("toto.###.tiff".to_string(), vec_toto),
128128
("foo.exr".to_string(), vec_foo),
129129
]);
130130
assert_eq!(expected, parse_result(source));
@@ -205,6 +205,22 @@ fn test_create_frame_string() {
205205
];
206206
let expected: String = "1-3,5".to_string();
207207
assert_eq!(expected, create_frame_string(source));
208+
#[allow(dead_code)]
209+
fn concat_line(main_string: String, frame_string: String) -> String {
210+
let buf: bool = false;
211+
if buf {
212+
let from: String = String::from("#####");
213+
main_string.replace(&from, &frame_string)
214+
} else {
215+
format!("{}@{}", main_string, frame_string)
216+
}
217+
}
218+
#[test]
219+
fn test_concat_line() {
220+
let main_string: String = String::from("toto");
221+
let frame_string: String = String::from("bar");
222+
let expected: String = String::from("toto@bar");
223+
assert_eq!(expected, concat_line(main_string, frame_string));
208224
}
209225
/// ## Basic listing of the library
210226
/// ### Description
@@ -258,7 +274,7 @@ pub fn extended_listing(root_path: String, frames: Vec<String>) -> Vec<String> {
258274
out_frames.push(key);
259275
} else {
260276
let to = value.first().unwrap();
261-
let from = String::from_utf8(vec![b'*'; to.len()]).unwrap();
277+
let from = String::from_utf8(vec![b'#'; to.len()]).unwrap();
262278
let new_path = &key.replace(&from, to);
263279
medata.push(get_exr_metada(&re, &root_path, &new_path));
264280
out_frames.push(format!("{}@{}", key, create_frame_string(value)));

src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ struct Args {
99
#[arg(short, long)]
1010
list: bool,
1111

12+
/// Display Buf format
13+
#[arg(short, long)]
14+
buf: bool,
15+
1216
/// Path to parse
1317
#[arg(default_value_t = String::from("./"), last = true)]
1418
path: String,

0 commit comments

Comments
 (0)