mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-25 14:36:34 +00:00
Add directory_and_stem and mkdir_p
This commit is contained in:
parent
3a2157e9b3
commit
a33620f555
@ -112,6 +112,23 @@ def file_is_editable(filepath):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def directory_and_stem(arg_path):
|
||||||
|
filepath = Path(arg_path)
|
||||||
|
stem = Path(filepath.stem)
|
||||||
|
while stem.suffixes and '' != stem.suffix:
|
||||||
|
stem = Path(stem.stem)
|
||||||
|
stem = str(stem)
|
||||||
|
return (filepath.parent, stem, filepath.suffixes,)
|
||||||
|
|
||||||
|
|
||||||
|
def mkdir_p(arg_path, mode=0o777):
|
||||||
|
'''
|
||||||
|
Reminder: mode only affects the last directory
|
||||||
|
'''
|
||||||
|
dirpath = Path(arg_path)
|
||||||
|
return dirpath.mkdir(mode=mode, parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
|
||||||
def write_text_file(filepath, filedata):
|
def write_text_file(filepath, filedata):
|
||||||
if not isinstance(filedata, str):
|
if not isinstance(filedata, str):
|
||||||
raise ValueError(f'filedata must be a str, got "{type(filedata)}"')
|
raise ValueError(f'filedata must be a str, got "{type(filedata)}"')
|
||||||
|
Loading…
Reference in New Issue
Block a user