Daddy PyLint is not happy

This commit is contained in:
Michał Gdula 2023-04-01 17:40:42 +00:00
parent ff1af6b888
commit 42375af3c3
4 changed files with 79 additions and 63 deletions

View file

@ -15,43 +15,46 @@ def compile_theme(theme_name, app_path):
print(f"Loading '{theme_name}' theme...")
# Set Paths
THEME_SRC = os.path.join(app_path, 'themes', theme_name)
THEME_DEST = os.path.join(app_path, 'static', 'theme')
theme_source = os.path.join(app_path, 'themes', theme_name)
theme_destination = os.path.join(app_path, 'static', 'theme')
# If the theme doesn't exist, exit
if not os.path.exists(THEME_SRC):
if not os.path.exists(theme_source):
print("Theme does not exist!")
sys.exit(1)
# If the destination folder doesn't exist, create it
if not os.path.exists(THEME_DEST):
os.makedirs(THEME_DEST)
if not os.path.exists(theme_destination):
os.makedirs(theme_destination)
# Theme source file doesn't exist, exit
if not os.path.join(THEME_SRC, 'style.sass'):
if not os.path.join(theme_source, 'style.sass'):
print("No sass file found!")
sys.exit(1)
# Compile the theme
with open(os.path.join(THEME_DEST, 'style.css'), encoding='utf-8', mode='w+') as file:
with open(os.path.join(theme_destination, 'style.css'),
encoding='utf-8', mode='w+') as file:
try:
file.write(sass.compile(filename=os.path.join(THEME_SRC, 'style.sass'),output_style='compressed'))
file.write(sass.compile(filename=os.path.join(theme_source, 'style.sass'),
output_style='compressed'))
except sass.CompileError as err:
print("Failed to compile!\n", err)
sys.exit(1)
print("Compiled successfully!")
# If the destination folder exists, remove it
if os.path.exists(os.path.join(THEME_DEST, 'fonts')):
if os.path.exists(os.path.join(theme_destination, 'fonts')):
try:
shutil.rmtree(os.path.join(THEME_DEST, 'fonts'))
shutil.rmtree(os.path.join(theme_destination, 'fonts'))
except Exception as err:
print("Failed to remove old fonts!\n", err)
sys.exit(1)
# Copy the fonts
try:
shutil.copytree(os.path.join(THEME_SRC, 'fonts'), os.path.join(THEME_DEST, 'fonts'))
shutil.copytree(os.path.join(theme_source, 'fonts'),
os.path.join(theme_destination, 'fonts'))
print("Fonts copied successfully!")
except Exception as err:
print("Failed to copy fonts!\n", err)