Changeset 6f951ca in flex_extract.git for source/python/classes/UioFiles.py
- Timestamp:
- Jan 15, 2019, 1:05:10 AM (5 years ago)
- Branches:
- master, ctbto, dev
- Children:
- d4696e0
- Parents:
- 2625ca8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/python/classes/UioFiles.py
r5cb0eaa r6f951ca 12 12 # - added pattern search in method list_files 13 13 # 14 # February 2018 - Anne Philipp (University of Vienna):14 # February - December 2018 - Anne Philipp (University of Vienna): 15 15 # - applied PEP8 style guide 16 16 # - added documentation … … 20 20 # - modified the class so that it is initiated with a pattern instead 21 21 # of suffixes. Gives more precision in selection of files. 22 # - added delete method 22 23 # 23 24 # @License: 24 # (C) Copyright 2014-2018. 25 # (C) Copyright 2014-2019. 26 # Anne Philipp, Leopold Haimberger 25 27 # 26 # This software is licensed under the terms of the Apache Licence Version 2.0 27 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 28 # 29 # @Class Decription: 30 # The class is for file manipulation. It is initiated with a regular 31 # expression pattern for this instance and can produce a list of Files 32 # from the given file pattern. These files can be deleted. 33 # 34 # @Class Content: 35 # - __init__ 36 # - __str__ 37 # - __list_files__ 38 # - delete_files 39 # 40 # @Class Attributes: 41 # - pattern 42 # - files 43 # 28 # This work is licensed under the Creative Commons Attribution 4.0 29 # International License. To view a copy of this license, visit 30 # http://creativecommons.org/licenses/by/4.0/ or send a letter to 31 # Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. 44 32 #******************************************************************************* 45 33 … … 51 39 import fnmatch 52 40 53 # software specific module from flex_extract41 # software specific modules from flex_extract 54 42 sys.path.append('../') 55 #import profiling56 43 from mods.tools import silent_remove, get_list_as_string 57 44 … … 61 48 62 49 class UioFiles(object): 63 '''Class to manipulate files. At initialisation it has the pattern 64 which stores a regular expression pattern for the files, the path 65 to the files and the files already. 50 '''Collection of files matching a specific pattern. 51 52 The pattern can contain regular expressions for the files. 53 The files are listed and can be transformed to a single string or 54 they can be deleted. 55 56 Attributes 57 ---------- 58 path : str 59 Directory where to list the files. 60 61 pattern : str 62 Regular expression pattern. For example: '\*.grb' 63 64 files : list of str 65 List of files matching the pattern in the path. 66 66 ''' 67 67 # -------------------------------------------------------------------------- 68 # CLASS FUNCTIONS68 # CLASS METHODS 69 69 # -------------------------------------------------------------------------- 70 70 def __init__(self, path, pattern): … … 73 73 Parameters 74 74 ---------- 75 path : :obj:`string`75 path : str 76 76 Directory where to list the files. 77 77 78 pattern : :obj:`string`78 pattern : str 79 79 Regular expression pattern. For example: '\*.grb' 80 80 … … 92 92 return 93 93 94 #@profiling.timefn 94 95 95 def _list_files(self, path): 96 96 '''Lists all files in the directory with the matching … … 99 99 Parameters 100 100 ---------- 101 path : :obj:`string`101 path : str 102 102 Path to the files. 103 103 … … 116 116 return 117 117 118 118 119 def __str__(self): 119 120 '''Converts the list of files into a single string. … … 125 126 Return 126 127 ------ 127 files_string : :obj:`string`128 files_string : str 128 129 The content of the list as a single string. 129 130 ''' … … 133 134 134 135 return files_string 136 135 137 136 138 def delete_files(self):
Note: See TracChangeset
for help on using the changeset viewer.