2023-01-01 14:31:28 +00:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
|
|
|
class Sassy():
|
|
|
|
def __init__(self, theme):
|
|
|
|
try:
|
|
|
|
import sass
|
|
|
|
except ImportError:
|
2023-01-06 15:47:22 +00:00
|
|
|
print("Error: libsass not found")
|
2023-01-01 14:31:28 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
2023-01-06 15:47:22 +00:00
|
|
|
path_to_sass = os.path.join('usr', 'themes', theme, 'style.scss')
|
2023-01-01 14:31:28 +00:00
|
|
|
|
|
|
|
if os.path.exists(path_to_sass):
|
2023-01-06 15:47:22 +00:00
|
|
|
print(f"Theme '{theme}' found at:", path_to_sass)
|
2023-01-01 14:31:28 +00:00
|
|
|
self.sass = sass
|
|
|
|
self.loadTheme(path_to_sass)
|
|
|
|
else:
|
|
|
|
print("Error: theme not found")
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
def loadTheme (self, theme):
|
|
|
|
with open('static/css/style.css', 'w') as f:
|
|
|
|
try:
|
|
|
|
f.write(self.sass.compile(filename=theme, output_style='compressed'))
|
2023-01-06 15:47:22 +00:00
|
|
|
print("Sass compiled successfully to:", f.name)
|
2023-01-01 14:31:28 +00:00
|
|
|
except self.sass.CompileError as e:
|
|
|
|
print("Error: sass compilation failed:\n", e)
|