tea.shell
Module¶
This module mimics some of the behaviors of the builtin shutil
module, adding logging to all operations and abstracting some other useful
shell commands (functions).
-
tea.shell.
search
(path, matcher='*', dirs=False, files=True)[source]¶ Recursive search function.
Parameters: - path – path to search recursively
- matcher – string pattern to search for or function that returns True/False for a file argument
- dirs – if True returns directories that match the pattern
- files – if True returns files that match the patter
-
tea.shell.
goto
(*args, **kwds)[source]¶ Context object for changing directory.
Usage:
>>> with goto(directory) as ok: ... if not ok: ... print 'Error' ... else: ... print 'All OK'
-
tea.shell.
mkdir
(path[, mode=0755])[source]¶ 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
-
tea.shell.
gcopy
(pattern, destination)[source]¶ Copy all file found by glob.glob(pattern) to destination directory
-
tea.shell.
move
(source, destination)[source]¶ 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.
-
tea.shell.
gmove
(pattern, destination)[source]¶ Move all file found by glob.glob(pattern) to destination directory
-
tea.shell.
remove
(path)[source]¶ 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.
-
tea.shell.
gremove
(pattern)[source]¶ Remove all file found by glob.glob(pattern)
Parameters: pattern (str) – Pattern of files to remove