This module mimics the behavior of the builtin shutil module from the standard python library, adding logging to all operations.
Also, it adds a few useful additional functions to the module.
Change the current working directory
Copy file or directory
Copy data and mode bits (“cp source destination”).
The destination may be a directory.
Parameters: | |
---|---|
Return type: | |
Returns: | True if the operation is successful, False otherwise. |
Copy data and all stat info (“cp -p source destination”).
The destination may be a directory.
Parameters: | |
---|---|
Return type: | |
Returns: | True if the operation is successful, False otherwise. |
Recursively copy a directory tree using copy2().
The destination directory must not already exist.
If the optional symlinks flag is true, symbolic links in the source tree result in symbolic links in the destination tree; if it is false, the contents of the files pointed to by symbolic links are copied.
Parameters: | |
---|---|
Return type: | |
Returns: | True if the operation is successful, False otherwise. |
Copy all file found by glob.glob(pattern) to destination directory
Move all file found by glob.glob(pattern) to destination directory
Context object for changing directory.
Usage:
>>> with goto(directory) as ok:
... if not ok:
... print 'Error'
... else:
... print 'All OK'
Create a leaf directory and all intermediate ones. Works like mkdir, except that any intermediate path segment (not just the rightmost) will be created if it does not exist. This is recursive.
Parameters: | |
---|---|
Return type: | |
Returns: | True if succeeded else False |
Recursively move a file or directory to another location.
If the destination is on our current file system, then simply use rename. Otherwise, copy source to the destination and then remove source.
Parameters: | |
---|---|
Return type: | |
Returns: | True if the operation is successful, False otherwise. |
Delete a file or directory
Parameters: | path (str) – Path to the file or directory that needs to be deleted. |
---|---|
Return type: | bool |
Returns: | True if the operation is successful, False otherwise. |
Delete a file
Parameters: | path (str) – Path to the file that needs to be deleted. |
---|---|
Return type: | bool |
Returns: | True if the operation is successful, False otherwise. |
Recursively delete a directory tree.
Parameters: | path (str) – Path to the directory that needs to be deleted. |
---|---|
Return type: | bool |
Returns: | True if the operation is successful, False otherwise. |
Recursive search function.
Parameters: |
|
---|
Split the string s using shell-like syntax