@@ -207,10 +207,11 @@ fn test_create_frame_string() {
207207 assert_eq ! ( expected, create_frame_string( source) ) ;
208208}
209209#[ allow( dead_code) ]
210- fn concat_line ( main_string : String , frame_string : String ) -> String {
211- let buf: bool = false ;
210+ /// This function is intend to keep padding in the string lile:
211+ /// aa.[0035-0036].exr
212+ fn concat_line ( main_string : String , frame_string : String , padding : String , buf : bool ) -> String {
212213 if buf {
213- let from: String = String :: from ( "#####" ) ;
214+ let from: String = String :: from ( padding ) ;
214215 main_string. replace ( & from, & frame_string)
215216 } else {
216217 format ! ( "{}@{}" , main_string, frame_string)
@@ -221,8 +222,16 @@ fn test_concat_line() {
221222 let main_string: String = String :: from ( "toto" ) ;
222223 let frame_string: String = String :: from ( "bar" ) ;
223224 let expected: String = String :: from ( "toto@bar" ) ;
224- assert_eq ! ( expected, concat_line( main_string, frame_string) ) ;
225+ assert_eq ! ( expected, concat_line( main_string, frame_string, "#####" . to_string ( ) , false ) ) ;
225226}
227+ #[ test]
228+ fn test_buf_concat_line ( ) {
229+ let main_string: String = String :: from ( "toto.#####.exr" ) ;
230+ let frame_string: String = String :: from ( "bar" ) ;
231+ let expected: String = String :: from ( "toto.bar.exr" ) ;
232+ assert_eq ! ( expected, concat_line( main_string, frame_string, "#####" . to_string( ) , true ) ) ;
233+ }
234+
226235/// ## Basic listing of the library
227236/// ### Description
228237///
@@ -232,14 +241,16 @@ fn test_concat_line() {
232241///
233242/// It take a `Vec<String>` of entries as an input
234243/// - Pack the frames
235- pub fn basic_listing ( frames : Vec < String > ) -> Vec < String > {
244+ pub fn basic_listing ( frames : Vec < String > , buf : bool ) -> Vec < String > {
236245 let frames_dict: HashMap < String , Vec < String > > = parse_result ( frames) ;
237246 let mut out_frames: Vec < String > = Vec :: new ( ) ;
238247 for ( key, value) in frames_dict {
239248 if value[ 0 ] == "None" && value. len ( ) == 1 {
240249 out_frames. push ( key) ;
241250 } else {
242- out_frames. push ( format ! ( "{}@{}" , key, create_frame_string( value) ) ) ;
251+ let to =value. first ( ) . unwrap ( ) ;
252+ let from = String :: from_utf8 ( vec ! [ b'#' ; to. len( ) ] ) . unwrap ( ) ;
253+ out_frames. push ( concat_line ( key, create_frame_string ( value) , from, buf ) ) ;
243254 }
244255 }
245256 out_frames
@@ -264,7 +275,7 @@ fn get_exr_metada(re: &Regex, root_path: &String, path: &String) -> String {
264275/// - Pack the frames
265276/// - Print the metada if the sequence is an exr sequence
266277/// - Return a Vector of path packed
267- pub fn extended_listing ( root_path : String , frames : Vec < String > ) -> Vec < String > {
278+ pub fn extended_listing ( root_path : String , frames : Vec < String > , buf : bool ) -> Vec < String > {
268279 let re: Regex = Regex :: new ( r".*.exr$" ) . unwrap ( ) ;
269280 let frames_dict: HashMap < String , Vec < String > > = parse_result ( frames) ;
270281 let mut out_frames: Vec < String > = Vec :: new ( ) ;
@@ -278,7 +289,7 @@ pub fn extended_listing(root_path: String, frames: Vec<String>) -> Vec<String> {
278289 let from = String :: from_utf8 ( vec ! [ b'#' ; to. len( ) ] ) . unwrap ( ) ;
279290 let new_path = & key. replace ( & from, to) ;
280291 medata. push ( get_exr_metada ( & re, & root_path, & new_path) ) ;
281- out_frames. push ( format ! ( "{}@{}" , key, create_frame_string( value) ) ) ;
292+ out_frames. push ( concat_line ( key, create_frame_string ( value) , from , buf ) ) ;
282293 }
283294 }
284295 out_frames. append ( & mut medata) ;
0 commit comments