sfepy.base.ioutils module¶
-
class
sfepy.base.ioutils.
InDir
(filename)[source]¶ Store the directory name a file is in, and prepend this name to other files.
Examples
>>> indir = InDir('output/file1') >>> print indir('file2')
-
sfepy.base.ioutils.
edit_filename
(filename, prefix='', suffix='', new_ext=None)[source]¶ Edit a file name by add a prefix, inserting a suffix in front of a file name extension or replacing the extension.
Parameters: filename : str
The file name.
prefix : str
The prefix to be added.
suffix : str
The suffix to be inserted.
new_ext : str, optional
If not None, it replaces the original file name extension.
Returns: new_filename : str
The new file name.
-
sfepy.base.ioutils.
ensure_path
(filename)[source]¶ Check if path to filename exists and if not, create the necessary intermediate directories.
-
sfepy.base.ioutils.
get_print_info
(n_step, fill=None)[source]¶ Returns the max. number of digits in range(n_step) and the corresponding format string.
Examples:
>>> get_print_info(11) (2, '%2d') >>> get_print_info(8) (1, '%1d') >>> get_print_info(100) (2, '%2d') >>> get_print_info(101) (3, '%3d') >>> get_print_info(101, fill='0') (3, '%03d')
-
sfepy.base.ioutils.
locate_files
(pattern, root_dir='.')[source]¶ Locate all files matching fiven filename pattern in and below supplied root directory.
-
sfepy.base.ioutils.
read_array
(fd, n_row, n_col, dtype)[source]¶ Read a NumPy array of shape (n_row, n_col) from the given file object and cast it to type dtype. If n_col is None, determine the number of columns automatically.
-
sfepy.base.ioutils.
read_token
(fd)[source]¶ Read a single token (sequence of non-whitespace characters) from the given file object.
Notes
Consumes the first whitespace character after the token.
-
sfepy.base.ioutils.
remove_files
(root_dir)[source]¶ Remove all files and directories in supplied root directory.