Commit 6609d289 authored by shadMod's avatar shadMod 💬

added compile_download

quick code cleanup and reformat
parent 1ab629e9
...@@ -24,18 +24,20 @@ from htmlmin import minify ...@@ -24,18 +24,20 @@ from htmlmin import minify
from .constants import UITWWW_DIR, BASE_DIR from .constants import UITWWW_DIR, BASE_DIR
from .utils import ReverseProxied, GunicornInstance from .utils import ReverseProxied, GunicornInstance
from .src.download.compile_download import CompileVersion
@click.group() @click.group()
def cli(): def cli():
""" Ubuntu-it website's command line utility """ """Ubuntu-it website's command line utility"""
pass pass
@cli.command("run") @cli.command("run")
@click.argument("data") @click.argument("data")
@click.option("-g", "--gunicorn-config", default=None, help="Path to a" @click.option(
"gunicorn config file") "-g", "--gunicorn-config", default=None, help="Path to a" "gunicorn config file"
)
@click.option("-p", "--port", default=8000, help="Bind that port") @click.option("-p", "--port", default=8000, help="Bind that port")
@click.option("--public", help="Make available to the public", is_flag=True) @click.option("--public", help="Make available to the public", is_flag=True)
@click.option("-w", "--workers", help="Number of workers to start", default=3) @click.option("-w", "--workers", help="Number of workers to start", default=3)
...@@ -81,9 +83,17 @@ def run(data, gunicorn_config, port, public, workers, debug): ...@@ -81,9 +83,17 @@ def run(data, gunicorn_config, port, public, workers, debug):
@click.option("-d", "--debug", help="Enable debug mode", is_flag=True) @click.option("-d", "--debug", help="Enable debug mode", is_flag=True)
def init(data, debug): def init(data, debug):
"""Initialize the data directory""" """Initialize the data directory"""
print("Initializing data directory:", data)
data_path = os.path.expanduser(os.path.abspath(data)) data_path = os.path.expanduser(os.path.abspath(data))
print("Initializing data directory:", data)
compiler = CompileVersion(
path_out=UITWWW_DIR + "/data/downloads.toml",
constants=UITWWW_DIR + "/src/download/assets/constants.json",
ignore_interim="mantic",
)
compiler.compile_download()
print("Compile download file")
uitwww.init_data_directory(data_path, debug) uitwww.init_data_directory(data_path, debug)
print("Created data directory:", data)
@cli.command("build_scss") @cli.command("build_scss")
...@@ -99,6 +109,4 @@ def build_scss(): ...@@ -99,6 +109,4 @@ def build_scss():
os.makedirs(os.path.dirname(path), exist_ok=True) os.makedirs(os.path.dirname(path), exist_ok=True)
# open file, compile and write css # open file, compile and write css
with open(path, "w") as fn: with open(path, "w") as fn:
fn.write(minify(compile_file( fn.write(minify(compile_file(f"{BASE_DIR}/assets/scss/{val}.scss")))
f"{BASE_DIR}/assets/scss/{val}.scss"
)))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment