dir_ops package
Submodules
dir_ops.base_dir_ops module
- class dir_ops.base_dir_ops.BaseDir(*args, **kwargs)[source]
Bases:
ParentClass
- INSTANCE_METHOD_ATTS = ['path']
- STATIC_METHOD_SUFFIX = '_dir'
- ascend(level_to_ascend: int = 1) BaseDir [source]
go up a x number directories -> “levels_to_ascend”
- static ascend_dir(dir: str, levels_to_ascend: int = 1) str [source]
go up a x number directories -> “levels_to_ascend”
- create_parents(*args, **kwargs)[source]
use recursion to travel all the way up the parent directories until we find one that exists, then unfold and create each directory
- get_rel(other_Dir: BaseDir) BaseDir [source]
Given a Dir object, find the relative Dir from Dir to self
- get_unique_Path(filename: str, **list_contents_Paths_kwargs) str [source]
finds a unique Path for the proposed filename based on the contents of the Directory if file.txt already exists in the dir, return file1.txt or file2.txt, etc
- inherited_kwargs = {}
- list_contents_Paths(block_dirs: bool = True, block_paths: bool = False, **kwargs) BasePaths [source]
- class dir_ops.base_dir_ops.BaseDirs(*args, given_Dirs=[], given_Paths=[], **kwargs)[source]
Bases:
ParentPluralList
- inherited_kwargs = {}
- class dir_ops.base_dir_ops.BasePath(*args, **kwargs)[source]
Bases:
BaseDir
- INSTANCE_METHOD_ATTS = ['path']
- STATIC_METHOD_SUFFIX = '_path'
- static get_filename(path: str) str [source]
returns the filename (‘file.txt’) from a long path (‘C:/path/to/file.txt’)
- get_rel(Dir_inst: BaseDir, path='') BasePath [source]
Given a Dir object, find the relative Path from Dir to self
dir_ops.decorators module
- dir_ops.decorators.base_instance_method(method)[source]
instance methods call the corresponding staticmethod Example: Dir_instance.exists(,*) calls Dir.exists_dir( Dir_instance.path,*,** )
dir_ops.local_dir_ops module
- class dir_ops.local_dir_ops.Path(*args, **kwargs)[source]
-
Inherits from the Dir class found in Dir.py Path (uppercase P) is a Path class, path (lowercase P) is a string with file absolute path
- static get_mtime_path(path, *args, **kwargs) datetime [source]
get the time of modification as a datetime object
dir_ops.remote_dir_ops module
- class dir_ops.remote_dir_ops.RemotePaths(*args, **kwargs)[source]
Bases:
RemoteDirs
,BasePaths
dir_ops.utils module
- dir_ops.utils.add_prefix_to_paths(prefix_path, relative_paths)[source]
adds prefix to a list of relaive paths
- dir_ops.utils.create_shortcut(target_Path, shortcut_Dir) None [source]
places a shortcut from target_Path to shortcut_Dir
- dir_ops.utils.get_env_var_path_delim() str [source]
Returns the delimitter for the OS’s path environment variables
- dir_ops.utils.is_dir(path: str) bool [source]
returns a boolean value to check if the path is a directory
- dir_ops.utils.is_file(path: str) bool [source]
returns a boolean value to check if the path is a file
- dir_ops.utils.print_to_from(print_off: bool, action_str: str, from_str: str, to_str: str)[source]
Copying C:/Users/path/file.txt -> C:/Users/newfile.txt
- dir_ops.utils.remove_hanging_slashes(path)[source]
removes ending slashes from paths turns “asdf/asdf//” into “asdf/sadf”
- dir_ops.utils.remove_prefix_from_paths(prefix_path, full_paths)[source]
Removes prefix from full paths