Reduced imports

This commit is contained in:
2Shirt 2019-04-11 20:50:21 -07:00
parent 1a8b6705e0
commit d33f78960d
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
3 changed files with 15 additions and 12 deletions

View file

@ -9,6 +9,7 @@ import sys
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
from collections import OrderedDict
from docopt import docopt
from functions.common import *
from functions.ufd import *
from settings.ufd import *
init_global_vars()

View file

@ -1,7 +1,9 @@
# Wizard Kit: Functions - UFD
import os
import re
import shutil
import pathlib
from functions.common import *
def case_insensitive_search(path, item):
@ -27,11 +29,11 @@ def case_insensitive_search(path, item):
)
# Done
if real_path:
return real_path
else:
if not real_path:
raise FileNotFoundError('{}/{}'.format(path, item))
return real_path
def find_path(path):
"""Find path case-insensitively, returns pathlib.Path obj."""
@ -103,7 +105,7 @@ def recursive_copy(source, dest, overwrite=True):
shutil.copytree(source, dest)
elif not dest.is_dir():
# Refusing to replace file with dir
raise GenericError('Refusing to replace file with dir: {}'.format(dest))
raise FileExistsError('Refusing to replace file: {}'.format(dest))
else:
# Dest exists and is a dir, merge dirs
for item in os.scandir(source):
@ -114,14 +116,14 @@ def recursive_copy(source, dest, overwrite=True):
shutil.copy2(source, dest)
elif not dest.is_file():
# Refusing to replace dir with file
raise GenericError('Refusing to replace dir with file: {}'.format(dest))
raise FileExistsError('Refusing to replace dir: {}'.format(dest))
elif overwrite:
# Dest file exists, deleting and replacing file
os.remove(dest)
shutil.copy2(source, dest)
else:
# Refusing to delete file when overwrite=False
raise GenericError('Refusing to delete file: {}'.format(dest))
raise FileExistsError('Refusing to delete file: {}'.format(dest))
if __name__ == '__main__':

View file

@ -1,7 +1,9 @@
# Wizard Kit: Settings - UFD
'''Wizard Kit: Settings - UFD'''
# pylint: disable=C0326,E0611
# vim: sts=2 sw=2 ts=2
from collections import OrderedDict
from settings.main import *
from settings.main import KIT_NAME_FULL,KIT_NAME_SHORT
# General
DOCSTRING = '''WizardKit: Build UFD
@ -31,7 +33,7 @@ Options:
'''
ISO_LABEL = '{}_LINUX'.format(KIT_NAME_SHORT)
UFD_LABEL = '{}_UFD'.format(KIT_NAME_SHORT)
UFD_SOURCES = ({
UFD_SOURCES = OrderedDict({
'Linux': {'Arg': '--linux', 'Type': 'ISO'},
'Linux (Minimal)': {'Arg': '--linux-minimal', 'Type': 'ISO'},
'WinPE': {'Arg': '--winpe', 'Type': 'ISO'},
@ -84,5 +86,3 @@ ITEMS = {
if __name__ == '__main__':
print("This file is not meant to be called directly.")
# vim: sts=2 sw=2 ts=2