From 36c8f2654e682d223190813ac81547d9bd380b5d Mon Sep 17 00:00:00 2001 From: krateng Date: Thu, 23 Dec 2021 05:17:19 +0100 Subject: [PATCH] Refactoring --- .github/workflows/pypi.yml | 12 +++++++----- maloja/server.py | 39 +++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 279a16e..fc9775b 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -13,14 +13,16 @@ jobs: - name: Check out the repo uses: actions/checkout@v2 - - name: Install dependencies - run: pip install wheel setuptools + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' - - name: Install Doreah (imported on build) - run: pip install doreah + - name: Install dependencies + run: pip install build doreah - name: Build package - run: python setup.py sdist bdist_wheel + run: python -m build - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/maloja/server.py b/maloja/server.py index c2d80d8..c15a6b2 100644 --- a/maloja/server.py +++ b/maloja/server.py @@ -1,9 +1,21 @@ -#!/usr/bin/env python +# technical +import sys +import signal +import os +from threading import Thread +import setproctitle +import pkg_resources +from css_html_js_minify import html_minify, css_minify +from wand.image import Image as WandImage # server stuff from bottle import Bottle, static_file, request, response, FormsDict, redirect, BaseRequest, abort import waitress +# doreah toolkit +from doreah.logging import log +from doreah.timing import Clock +from doreah import auth # rest of the project from . import database @@ -12,19 +24,8 @@ from .malojauri import uri_to_internal, remove_identical from .globalconf import malojaconfig, data_dir from .jinjaenv.context import jinja_environment from .apis import init_apis -# doreah toolkit -from doreah.logging import log -from doreah.timing import Clock -from doreah import auth -# technical -from threading import Thread -import sys -import signal -import os -import setproctitle -import pkg_resources -from css_html_js_minify import html_minify, css_minify -from wand.image import Image as WandImage + + ###### @@ -50,18 +51,18 @@ setproctitle.setproctitle("Maloja") def generate_css(): - css = "" + cssstr = "" for file in os.listdir(os.path.join(STATICFOLDER,"css")): with open(os.path.join(STATICFOLDER,"css",file),"r") as filed: - css += filed.read() + cssstr += filed.read() for file in os.listdir(data_dir['css']()): if file.endswith(".css"): with open(os.path.join(data_dir['css'](file)),"r") as filed: - css += filed.read() + cssstr += filed.read() - css = css_minify(css) - return css + cssstr = css_minify(cssstr) + return cssstr css = generate_css()