#NEWLINE# def EWFGlobPathSpec( file_system , path_spec ) : #NEWLINE# #INDENT# 'Globs for path specifications according to the EWF naming schema.\n\n  Args:\n    file_system: the file system object (instance of FileSystem).\n    path_spec: the path specification (instance of PathSpec).\n\n  Returns:\n    A list of the path specifications that match the glob.\n\n  Raises:\n    PathSpecError: if the path specification is invalid.\n    RuntimeError: if the maximum number of supported segment files is\n                  reached.\n  ' #NEWLINE# if ( not path_spec . HasParent ( ) ) : #NEWLINE# #INDENT# raise errors . PathSpecError ( 'Unsupported path specification without parent.' ) #NEWLINE# #UNINDENT# parent_path_spec = path_spec . parent #NEWLINE# parent_location = getattr ( parent_path_spec , 'location' , None ) #NEWLINE# if ( not parent_location ) : #NEWLINE# #INDENT# raise errors . PathSpecError ( 'Unsupported parent path specification without location.' ) #NEWLINE# #UNINDENT# ( parent_location , _ , segment_extension ) = parent_location . rpartition ( '.' ) #NEWLINE# segment_extension_start = segment_extension [ 0 ] #NEWLINE# segment_extension_length = len ( segment_extension ) #NEWLINE# if ( ( segment_extension_length not in [ 3 , 4 ] ) or ( not segment_extension . endswith ( '01' ) ) or ( ( segment_extension_length == 3 ) and ( segment_extension_start not in [ 'E' , 'e' , 's' ] ) ) or ( ( segment_extension_length == 4 ) and ( not segment_extension . startswith ( 'Ex' ) ) ) ) : #NEWLINE# #INDENT# raise errors . PathSpecError ( 'Unsupported parent path specification invalid segment file extension: {0:s}' . format ( segment_extension ) ) #NEWLINE# #UNINDENT# segment_number = 1 #NEWLINE# segment_files = [ ] #NEWLINE# while True : #NEWLINE# #INDENT# segment_location = '{0:s}.{1:s}' . format ( parent_location , segment_extension ) #NEWLINE# kwargs = path_spec_factory . Factory . GetProperties ( parent_path_spec ) #NEWLINE# kwargs [ 'location' ] = segment_location #NEWLINE# if ( parent_path_spec . parent is not None ) : #NEWLINE# #INDENT# kwargs [ 'parent' ] = parent_path_spec . parent #NEWLINE# #UNINDENT# segment_path_spec = path_spec_factory . Factory . NewPathSpec ( parent_path_spec . type_indicator , ** kwargs ) #NEWLINE# if ( not file_system . FileEntryExistsByPathSpec ( segment_path_spec ) ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# segment_files . append ( segment_path_spec ) #NEWLINE# segment_number += 1 #NEWLINE# if ( segment_number <= 99 ) : #NEWLINE# #INDENT# if ( segment_extension_length == 3 ) : #NEWLINE# #INDENT# segment_extension = '{0:s}{1:02d}' . format ( segment_extension_start , segment_number ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( segment_extension_length == 4 ) : #NEWLINE# #INDENT# segment_extension = '{0:s}x{1:02d}' . format ( segment_extension_start , segment_number ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# segment_index = ( segment_number - 100 ) #NEWLINE# if ( segment_extension_start in [ 'e' , 's' ] ) : #NEWLINE# #INDENT# letter_offset = ord ( 'a' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# letter_offset = ord ( 'A' ) #NEWLINE# #UNINDENT# ( segment_index , remainder ) = divmod ( segment_index , 26 ) #NEWLINE# third_letter = chr ( ( letter_offset + remainder ) ) #NEWLINE# ( segment_index , remainder ) = divmod ( segment_index , 26 ) #NEWLINE# second_letter = chr ( ( letter_offset + remainder ) ) #NEWLINE# first_letter = chr ( ( ord ( segment_extension_start ) + segment_index ) ) #NEWLINE# if ( first_letter in [ '[' , '{' ] ) : #NEWLINE# #INDENT# raise RuntimeError ( 'Unsupported number of segment files.' ) #NEWLINE# #UNINDENT# if ( segment_extension_length == 3 ) : #NEWLINE# #INDENT# segment_extension = '{0:s}{1:s}{2:s}' . format ( first_letter , second_letter , third_letter ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( segment_extension_length == 4 ) : #NEWLINE# #INDENT# segment_extension = '{0:s}x{1:s}{2:s}' . format ( first_letter , second_letter , third_letter ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return segment_files