PSCF v1.1
|
Utilities for manipulating files and paths. More...
Classes | |
class | Directory |
Class that represents a directory. More... | |
class | File |
Class that contains metadata for a file. More... | |
Functions | |
def | relative_path (path1, path2) |
Generates relative path of path2 relative to path1. More... | |
def | chdirs (dir) |
Change current working directory and create dir if necessary. More... | |
def | open_w (path) |
Open file with specified path for writing, return file object. More... | |
def | rm (path) |
Remove a file if possible (if the path exists and it is a file). More... | |
def | mv (old_path, new_path) |
Rename a file or directory, creating any necessary parent directories. More... | |
Utilities for manipulating files and paths.
def pscfpp.file.relative_path | ( | path1, | |
path2 | |||
) |
Generates relative path of path2 relative to path1.
The paths path1 and path2 must be either absolute paths or relative paths defined relative to the same directory.
path1 | reference path |
path2 | path of interest |
def pscfpp.file.chdirs | ( | dir | ) |
Change current working directory and create dir if necessary.
This function attempts to change the current working directory to the directory specified by argument dir (like os.chdir), but first checks if the directory exists, and creates the directory and any missing parent directories if these do not yet exist.
dir | directory to change to |
def pscfpp.file.open_w | ( | path | ) |
Open file with specified path for writing, return file object.
Similar to built-in function open(path,'w'), except that open_w will create any non-existent directories in the path as needed.
path | path for new file |
Definition at line 57 of file file.py.
Referenced by pscfpp.make.MakeMaker.find().
def pscfpp.file.rm | ( | path | ) |
def pscfpp.file.mv | ( | old_path, | |
new_path | |||
) |
Rename a file or directory, creating any necessary parent directories.
Rename a file or directory. Similar to os.rename, except that this function will create any non-existent directories in the new path as needed.
old_path | path of file or directory to be renamed |
new_path | new path for file or directory |