@@ -318,13 +318,64 @@ fn test_continuity() {
318318 assert_eq ! ( expected, group_continuity( & source) ) ;
319319}
320320#[ test]
321- fn test_create_frame_string ( ) {
322- let source: Vec < String > = vec ! [
323- "001" . to_string( ) ,
324- "005" . to_string( ) ,
325- "003" . to_string( ) ,
326- "002" . to_string( ) ,
327- ] ;
328- let expected: String = "1-3,5" . to_string ( ) ;
329- assert_eq ! ( expected, create_frame_string( source) ) ;
321+ fn test_convert_vec_to_str ( ) {
322+ let source: Vec < Vec < isize > > = vec ! [ vec![ 1 , 2 , 3 ] , vec![ 5 , 6 , 7 ] , vec![ 11 , 12 ] , vec![ 45 ] ] ;
323+ let expected: String = "1-3,5-7,11-12,45" . to_string ( ) ;
324+ assert_eq ! ( expected, convert_vec_to_str( source) ) ;
325+ }
326+
327+ fn concat_line ( main_string : String , frame_string : String ) -> String {
328+ let buf: bool = false ;
329+ if buf {
330+ let from: String = String :: from ( "#####" ) ;
331+ main_string. replace ( & from, & frame_string)
332+ } else {
333+ format ! ( "{}@{}" , main_string, frame_string)
334+ }
335+ }
336+ #[ test]
337+ fn test_concat_line ( ) {
338+ let main_string: String = String :: from ( "toto" ) ;
339+ let frame_string: String = String :: from ( "bar" ) ;
340+ let expected: String = String :: from ( "toto@bar" ) ;
341+ assert_eq ! ( expected, concat_line( main_string, frame_string) ) ;
342+ }
343+ pub fn basic ( frames : Vec < String > ) -> Vec < String > {
344+ let frames_dict: HashMap < String , Vec < String > > = parse_result ( frames) ;
345+ let mut out_frames: Vec < String > = Vec :: new ( ) ;
346+ for ( key, value) in frames_dict {
347+ if value[ 0 ] == "None" && value. len ( ) == 1 {
348+ out_frames. push ( key) ;
349+ } else {
350+ let i = convert_vec ( value) ;
351+ let j = group_continuity ( & i) ;
352+ let k = convert_vec_to_str ( j) ;
353+ out_frames. push ( concat_line ( key, k) ) ;
354+ }
355+ }
356+ out_frames
357+ }
358+
359+ pub fn listing ( root_path : String , frames : Vec < String > ) -> Vec < String > {
360+ let re: Regex = Regex :: new ( r".*.exr$" ) . unwrap ( ) ;
361+ let frames_dict: HashMap < String , Vec < String > > = parse_result ( frames) ;
362+ let mut out_frames: Vec < String > = Vec :: new ( ) ;
363+ for ( key, value) in frames_dict {
364+ if value[ 0 ] == "None" && value. len ( ) == 1 {
365+ out_frames. push ( key) ;
366+ } else {
367+ let to = value. first ( ) . unwrap ( ) ;
368+ let from = String :: from_utf8 ( vec ! [ b'#' ; to. len( ) ] ) . unwrap ( ) ;
369+ let new_path = & key. replace ( & from, to) ;
370+ if re. is_match ( new_path) {
371+ let path = format ! ( "{}{}" , root_path, new_path) ;
372+ read_meta ( path) ;
373+ } ;
374+ let i = convert_vec ( value) ;
375+ let j = group_continuity ( & i) ;
376+ let k = convert_vec_to_str ( j) ;
377+ out_frames. push ( concat_line ( key, k) ) ;
378+ }
379+ }
380+ out_frames
330381}
0 commit comments