Changeset 8146
- Timestamp:
- Mar 11, 2011, 3:52:42 PM (13 years ago)
- Location:
- trunk/anuga_core/source/anuga/utilities
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/utilities/file_utils.py
r8109 r8146 82 82 83 83 84 ##85 # @brief Delete directory and all sub-directories.86 # @param path Path to the directory to delete.87 84 def del_dir(path): 88 85 """Recursively delete directory path and all its contents … … 104 101 105 102 106 ##107 # @brief ??108 # @param path109 # @param __func__110 # @param verbose True if this function is to be verbose.111 # @note ANOTHER OPTION, IF NEED IN THE FUTURE, Nick B 7/2007112 103 def rmgeneric(path, func, verbose=False): 113 104 ERROR_STR= """Error removing %(path)s, %(error)s """ … … 120 111 121 112 122 ##123 # @brief Remove directory and all sub-directories.124 # @param path Filesystem path to directory to remove.125 # @param verbose True if this function is to be verbose.126 113 def removeall(path, verbose=False): 127 114 if not os.path.isdir(path): … … 139 126 140 127 141 ##142 # @brief Create a standard filename.143 # @param datadir Directory where file is to be created.144 # @param filename Filename 'stem'.145 # @param format Format of the file, becomes filename extension.146 # @param size Size of file, becomes part of filename.147 # @param time Time (float), becomes part of filename.148 # @return The complete filename path, including directory.149 # @note The containing directory is created, if necessary.150 128 def create_filename(datadir, filename, format, size=None, time=None): 129 """Create a standard filename. 130 131 datadir directory where file is to be created 132 filename filename 'stem' 133 format format of the file, becomes filename extension 134 size size of file, becomes part of filename 135 time time (float), becomes part of filename 136 137 Returns the complete filename path, including directory. 138 139 The containing directory is created, if necessary. 140 """ 141 151 142 FN = check_dir(datadir) + filename 152 143 … … 162 153 163 154 164 ##165 # @brief Get all files with a standard name and a given set of attributes.166 # @param datadir Directory files must be in.167 # @param filename Filename stem.168 # @param format Filename extension.169 # @param size Filename size.170 # @return A list of fielnames (including directory) that match the attributes.171 155 def get_files(datadir, filename, format, size): 172 156 """Get all file (names) with given name, size and format … … 181 165 182 166 183 ##184 # @brief Find all files in a directory that contain a given string.185 # @param look_in_dir Path to the directory to look in.186 # @param base_name String that files must contain.187 # @param verbose True if this function is to be verbose.188 167 def get_all_directories_with_name(look_in_dir='', base_name='', verbose=False): 189 168 ''' … … 215 194 216 195 217 ##218 # @brief Find all SWW files in a directory with given stem name.219 # @param look_in_dir The directory to look in.220 # @param base_name The file stem name.221 # @param verbose True if this function is to be verbose.222 # @return A list of found filename strings.223 # @note Will accept 'base_name' with or without '.sww' extension.224 # @note If no files found, raises IOError exception.225 196 def get_all_swwfiles(look_in_dir='', base_name='', verbose=False): 226 197 ''' … … 259 230 260 231 261 ##262 # @brief Find all files in a directory that contain a string and have extension.263 # @param look_in_dir Path to the directory to look in.264 # @param base_name Stem filename of the file(s) of interest.265 # @param extension Extension of the files to look for.266 # @param verbose True if this function is to be verbose.267 # @return A list of found filename strings.268 # @note If no files found, raises IOError exception.269 232 def get_all_files_with_extension(look_in_dir='', 270 233 base_name='', … … 317 280 """ 318 281 319 ##320 # @brief copies a file or sequence to destination directory.321 # @param dest The destination directory to copy to.322 # @param file A filename string or sequence of filename strings.323 282 def copy_file_or_sequence(dest, file): 324 283 if hasattr(file, '__iter__'): -
trunk/anuga_core/source/anuga/utilities/numerical_tools.py
r8125 r8146 230 230 231 231 232 ##233 # @brief Ensure that a sequence is a numeric array of the required type.234 # @param A The sequence object to convert to a numeric array.235 # @param typecode The required numeric type of object A (a numeric dtype).236 # @return A numeric array of the required type.237 232 def ensure_numeric(A, typecode=None): 238 233 """Ensure that sequence is a numeric array. … … 375 370 ################################################################################ 376 371 377 ##378 # @brief Decide if an object is a numeric package object with datatype of float.379 # @param obj The object to decide on.380 # @return True if 'obj' is a numeric package object, and some sort of float.381 372 def is_num_float(obj): 382 373 '''Is an object a numeric package float object?''' … … 387 378 return False 388 379 389 ##390 # @brief Decide if an object is a numeric package object with datatype of int.391 # @param obj The object to decide on.392 # @return True if 'obj' is a numeric package object, and some sort of int.393 380 def is_num_int(obj): 394 381 '''Is an object a numeric package int object?''' -
trunk/anuga_core/source/anuga/utilities/terminal_width.py
r6909 r8146 8 8 ###### 9 9 10 ##11 # @brief Get the current terminal width.12 # @return The terminal width in characters.13 # @note If the width cannot be found, return 80 as a default.14 10 def terminal_width(): 11 """Get the current terminal width. 12 13 Returns the terminal width in characters. 14 15 If the width cannot be found, return 80 as a default. 16 """ 17 15 18 # First, try Windows. 16 19 try: -
trunk/anuga_core/source/anuga/utilities/test_system_tools.py
r7486 r8146 227 227 ################################################################################ 228 228 229 ##230 # @brief Helper function to write a list of strings to a NetCDF file.231 # @param filename Path to the file to write.232 # @param l The list of strings to write.233 229 def helper_write_msh_file(self, filename, l): 234 230 # open the NetCDF file … … 250 246 251 247 252 ##253 # @brief Helper function to read a NetCDF file and return a list of strings.254 # @param filename Path to the file to read.255 # @return A list of strings from the file.256 248 def helper_read_msh_file(self, filename): 257 249 fid = NetCDFFile(filename, netcdf_mode_r)
Note: See TracChangeset
for help on using the changeset viewer.