Changeset 0f89116 in flex_extract.git for Source/Python/Classes/UioFiles.py
- Timestamp:
- Dec 19, 2019, 8:07:12 PM (4 years ago)
- Branches:
- master, ctbto, dev
- Children:
- a73c0f6
- Parents:
- 0d99607
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Source/Python/Classes/UioFiles.py
r44174de r0f89116 42 42 43 43 # software specific modules from flex_extract 44 #pylint: disable=wrong-import-position 44 45 sys.path.append('../') 45 46 from Mods.tools import silent_remove, get_list_as_string 47 #pylint: enable=wrong-import-position 46 48 47 49 # ------------------------------------------------------------------------------ … … 50 52 51 53 class UioFiles(object): 52 '''Collection of files matching a specific pattern.54 """Collection of files matching a specific pattern. 53 55 54 56 The pattern can contain regular expressions for the files. … … 62 64 63 65 pattern : str 64 Regular expression pattern. For example: ' \*.grb'66 Regular expression pattern. For example: '*.grb' 65 67 66 68 files : list of str 67 69 List of files matching the pattern in the path. 68 '''70 """ 69 71 # -------------------------------------------------------------------------- 70 72 # CLASS METHODS 71 73 # -------------------------------------------------------------------------- 72 74 def __init__(self, path, pattern): 73 '''Assignes a specific pattern for these files.75 """Assignes a specific pattern for these files. 74 76 75 77 Parameters … … 79 81 80 82 pattern : str 81 Regular expression pattern. For example: ' \*.grb'83 Regular expression pattern. For example: '*.grb' 82 84 83 85 Return 84 86 ------ 85 87 86 '''88 """ 87 89 88 90 self.path = path … … 96 98 97 99 def _list_files(self, path): 98 '''Lists all files in the directory with the matching100 """Lists all files in the directory with the matching 99 101 regular expression pattern. 100 102 … … 107 109 ------ 108 110 109 '''111 """ 110 112 # Get the absolute path 111 113 path = os.path.abspath(path) 112 114 113 115 # get all files in the dir and subdir as absolut path 116 # pylint: disable=W0612 114 117 for root, dirnames, filenames in os.walk(path): 115 118 for filename in fnmatch.filter(filenames, self.pattern): … … 120 123 121 124 def __str__(self): 122 '''Converts the list of files into a single string.125 """Converts the list of files into a single string. 123 126 The entries are sepereated by "," sign. 124 127 … … 130 133 files_string : str 131 134 The content of the list as a single string. 132 '''135 """ 133 136 134 137 filenames = [os.path.basename(f) for f in self.files] … … 139 142 140 143 def delete_files(self): 141 '''Deletes the files.144 """Deletes the files. 142 145 143 146 Parameters … … 147 150 ------ 148 151 149 '''152 """ 150 153 151 154 for old_file in self.files:
Note: See TracChangeset
for help on using the changeset viewer.