mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-10 23:44:16 +00:00
refactor folder to directory
This commit is contained in:
@@ -16,7 +16,7 @@ TMPSUFFIX = '.dotdrop'
|
||||
|
||||
|
||||
def clean(path):
|
||||
'''Delete file or folder.'''
|
||||
'''Delete file or directory.'''
|
||||
if not os.path.exists(path):
|
||||
return
|
||||
if os.path.islink(path):
|
||||
@@ -33,13 +33,13 @@ def get_string(length):
|
||||
return ''.join(random.choice(alpha) for _ in range(length))
|
||||
|
||||
|
||||
def get_tempfolder():
|
||||
'''Get a temporary folder'''
|
||||
def get_tempdir():
|
||||
'''Get a temporary directory'''
|
||||
return tempfile.mkdtemp(suffix=TMPSUFFIX)
|
||||
|
||||
|
||||
def create_random_file(folder, content=None, binary=False):
|
||||
'''Create a new file in folder with random content.'''
|
||||
def create_random_file(directory, content=None, binary=False):
|
||||
'''Create a new file in directory with random content.'''
|
||||
fname = get_string(8)
|
||||
mode = 'w'
|
||||
if binary:
|
||||
@@ -49,14 +49,14 @@ def create_random_file(folder, content=None, binary=False):
|
||||
content = bytes(get_string(100), 'ascii')
|
||||
else:
|
||||
content = get_string(100)
|
||||
path = os.path.join(folder, fname)
|
||||
path = os.path.join(directory, fname)
|
||||
with open(path, mode) as f:
|
||||
f.write(content)
|
||||
return path, content
|
||||
|
||||
|
||||
def create_dir(path):
|
||||
'''Create a folder'''
|
||||
'''Create a directory'''
|
||||
if not os.path.exists(path):
|
||||
os.mkdir(path)
|
||||
return path
|
||||
@@ -93,10 +93,10 @@ def get_dotfile_from_yaml(dic, path):
|
||||
return [d for d in dotfiles.values() if d['src'] == src][0]
|
||||
|
||||
|
||||
def create_fake_config(folder, configname='config.yaml',
|
||||
def create_fake_config(directory, configname='config.yaml',
|
||||
dotpath='dotfiles', backup=True, create=True):
|
||||
'''Create a fake config file'''
|
||||
path = os.path.join(folder, configname)
|
||||
path = os.path.join(directory, configname)
|
||||
with open(path, 'w') as f:
|
||||
f.write('config:\n')
|
||||
f.write(' backup: %s\n' % (str(backup)))
|
||||
|
||||
Reference in New Issue
Block a user