Changeset 54a8a01 in flex_extract.git for python/UioFiles.py
- Timestamp:
- Aug 31, 2018, 7:50:37 AM (6 years ago)
- Branches:
- master, ctbto, dev
- Children:
- 597d4d1
- Parents:
- e1228f3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/UioFiles.py
rff99eae r54a8a01 34 34 # @Class Content: 35 35 # - __init__ 36 # - list_files 36 # - __str__ 37 # - __list_files__ 37 38 # - delete_files 38 39 # … … 51 52 # software specific module from flex_extract 52 53 #import profiling 53 from tools import silent_remove 54 from tools import silent_remove, get_list_as_string 54 55 55 56 # ------------------------------------------------------------------------------ … … 66 67 # CLASS FUNCTIONS 67 68 # -------------------------------------------------------------------------- 68 def __init__(self, pat tern):69 def __init__(self, path, pattern): 69 70 ''' 70 71 @Description: … … 75 76 Description see class documentation. 76 77 78 path: string 79 Directory where to list the files. 80 77 81 pattern: string 78 82 Regular expression pattern. For example: '*.grb' … … 82 86 ''' 83 87 88 self.path = path 84 89 self.pattern = pattern 85 90 self.files = None 91 92 self.__list_files__(self.path) 86 93 87 94 return 88 95 89 96 #@profiling.timefn 90 def list_files(self, path, callid=0):97 def __list_files__(self, path, callid=0): 91 98 ''' 92 99 @Description: … … 99 106 100 107 path: string 101 Directory where to listthe files.108 Path to the files. 102 109 103 110 callid: integer … … 129 136 if subdirs: 130 137 for subdir in subdirs: 131 self. list_files(os.path.join(path, subdir), callid=1)138 self.__list_files__(os.path.join(path, subdir), callid=1) 132 139 133 140 return 141 142 def __str__(self): 143 ''' 144 @Description: 145 Converts the list of files into a single string. 146 The entries are sepereated by "," sign. 147 148 @Input: 149 self: instance of UioFiles 150 Description see class documentation. 151 152 @Return: 153 files_string: string 154 The content of the list as a single string. 155 ''' 156 157 filenames = [os.path.basename(f) for f in self.files] 158 files_string = get_list_as_string(filenames, concatenate_sign=', ') 159 160 return files_string 134 161 135 162 def delete_files(self):
Note: See TracChangeset
for help on using the changeset viewer.