mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-08 14:19:16 +00:00
docstring
This commit is contained in:
@@ -18,7 +18,7 @@ TMPSUFFIX = '.dotdrop'
|
||||
|
||||
|
||||
def clean(path):
|
||||
'''Delete file or directory.'''
|
||||
"""Delete file or directory"""
|
||||
if not os.path.exists(path):
|
||||
return
|
||||
if os.path.islink(path):
|
||||
@@ -30,19 +30,19 @@ def clean(path):
|
||||
|
||||
|
||||
def get_string(length):
|
||||
'''Get a random string of length "length".'''
|
||||
"""Get a random string of length 'length'"""
|
||||
alpha = string.ascii_uppercase + string.digits
|
||||
return ''.join(random.choice(alpha) for _ in range(length))
|
||||
|
||||
|
||||
def get_tempdir():
|
||||
'''Get a temporary directory'''
|
||||
"""Get a temporary directory"""
|
||||
return tempfile.mkdtemp(suffix=TMPSUFFIX)
|
||||
|
||||
|
||||
def create_random_file(directory, content=None,
|
||||
binary=False, template=False):
|
||||
'''Create a new file in directory with random content.'''
|
||||
"""Create a new file in directory with random content"""
|
||||
fname = get_string(8)
|
||||
mode = 'w'
|
||||
if binary:
|
||||
@@ -65,7 +65,7 @@ def create_random_file(directory, content=None,
|
||||
|
||||
|
||||
def edit_content(path, newcontent, binary=False):
|
||||
'''edit file content'''
|
||||
"""edit file content"""
|
||||
mode = 'w'
|
||||
if binary:
|
||||
mode = 'wb'
|
||||
@@ -74,14 +74,14 @@ def edit_content(path, newcontent, binary=False):
|
||||
|
||||
|
||||
def create_dir(path):
|
||||
'''Create a directory'''
|
||||
"""Create a directory"""
|
||||
if not os.path.exists(path):
|
||||
os.mkdir(path)
|
||||
return path
|
||||
|
||||
|
||||
def load_config(confpath, profile):
|
||||
'''Load the config file from path'''
|
||||
"""Load the config file from path"""
|
||||
conf = Cfg(confpath)
|
||||
opts = conf.get_settings()
|
||||
opts['dry'] = False
|
||||
@@ -97,14 +97,14 @@ def load_config(confpath, profile):
|
||||
|
||||
|
||||
def get_path_strip_version(path):
|
||||
'''Return the path of a file as stored in yaml config'''
|
||||
"""Return the path of a file as stored in yaml config"""
|
||||
path = strip_home(path)
|
||||
path = path.lstrip('.' + os.sep)
|
||||
return path
|
||||
|
||||
|
||||
def get_dotfile_from_yaml(dic, path):
|
||||
'''Return the dotfile from the yaml dictionary'''
|
||||
"""Return the dotfile from the yaml dictionary"""
|
||||
# path is not the file in dotpath but on the FS
|
||||
dotfiles = dic['dotfiles']
|
||||
src = get_path_strip_version(path)
|
||||
@@ -113,7 +113,7 @@ def get_dotfile_from_yaml(dic, path):
|
||||
|
||||
def create_fake_config(directory, configname='config.yaml',
|
||||
dotpath='dotfiles', backup=True, create=True):
|
||||
'''Create a fake config file'''
|
||||
"""Create a fake config file"""
|
||||
path = os.path.join(directory, configname)
|
||||
workdir = os.path.join(directory, 'workdir')
|
||||
with open(path, 'w') as f:
|
||||
|
||||
Reference in New Issue
Block a user