improved smart_copy utility function
This commit is contained in:
parent
39fddbf121
commit
a01fd4262c
1 changed files with 7 additions and 6 deletions
13
src/util.py
13
src/util.py
|
@ -2,7 +2,7 @@ from .constants import tmp_dir
|
||||||
|
|
||||||
from importlib.machinery import SourceFileLoader
|
from importlib.machinery import SourceFileLoader
|
||||||
from os import system, makedirs
|
from os import system, makedirs
|
||||||
from shutil import copy
|
from os.path import dirname
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,17 +44,18 @@ def smart_mkdir(path: str):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def smart_copy(src: str, dst: str):
|
def smart_copy(src: str, dst: str, mode="644"):
|
||||||
"""
|
"""
|
||||||
Copies src to dst.
|
Copies src to dst.
|
||||||
Errors if parent directory/directories of dst does not exist.
|
Automatically creates parent directory/directories of dst does not exist already.
|
||||||
|
|
||||||
arguments:
|
parameters:
|
||||||
src: A path-like object or string pointing to a file.
|
src: A path-like object or string pointing to a file or a directory.
|
||||||
dst: A path-like object or string pointing to a file or a directory.
|
dst: A path-like object or string pointing to a file or a directory.
|
||||||
|
mode: Permission mode (as in chmod). Defaults to 644 (rw-r--r--)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
copy(src, dst)
|
system(f"install -Dm{mode} {src} {dst}")
|
||||||
|
|
||||||
|
|
||||||
def load_dconf(file_name: str):
|
def load_dconf(file_name: str):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue