mirror of
https://github.com/krateng/maloja.git
synced 2025-04-12 07:00:02 +03:00
Remove file path context managers, GH-390
This commit is contained in:
parent
968bea14d9
commit
5a95d4e056
@ -165,16 +165,16 @@ def login():
|
||||
@webserver.route("/media/<name>.<ext>")
|
||||
def static(name,ext):
|
||||
assert ext in ["txt","ico","jpeg","jpg","png","less","js","ttf","css"]
|
||||
with resources.files('maloja') / 'web' / 'static' as staticfolder:
|
||||
response = static_file(ext + "/" + name + "." + ext,root=staticfolder)
|
||||
staticfolder = resources.files('maloja') / 'web' / 'static'
|
||||
response = static_file(ext + "/" + name + "." + ext,root=staticfolder)
|
||||
response.set_header("Cache-Control", "public, max-age=3600")
|
||||
return response
|
||||
|
||||
# new, direct reference
|
||||
@webserver.route("/static/<path:path>")
|
||||
def static(path):
|
||||
with resources.files('maloja') / 'web' / 'static' as staticfolder:
|
||||
response = static_file(path,root=staticfolder)
|
||||
staticfolder = resources.files('maloja') / 'web' / 'static'
|
||||
response = static_file(path,root=staticfolder)
|
||||
response.set_header("Cache-Control", "public, max-age=3600")
|
||||
return response
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from importlib import resources
|
||||
try:
|
||||
from setuptools import distutils
|
||||
except ImportError:
|
||||
import distutils
|
||||
from doreah.io import col, ask, prompt
|
||||
|
||||
from .pkg_global.conf import data_dir, dir_settings, malojaconfig, auth
|
||||
@ -22,15 +19,14 @@ ext_apikeys = [
|
||||
|
||||
|
||||
def copy_initial_local_files():
|
||||
with resources.files("maloja") / 'data_files' as folder:
|
||||
for cat in dir_settings:
|
||||
if dir_settings[cat] is None:
|
||||
continue
|
||||
data_file_source = resources.files("maloja") / 'data_files'
|
||||
for cat in dir_settings:
|
||||
if dir_settings[cat] is None:
|
||||
continue
|
||||
if cat == 'config' and malojaconfig.readonly:
|
||||
continue
|
||||
|
||||
if cat == 'config' and malojaconfig.readonly:
|
||||
continue
|
||||
|
||||
distutils.dir_util.copy_tree(os.path.join(folder,cat),dir_settings[cat],update=False)
|
||||
shutil.copytree(data_file_source / cat, dir_settings[cat])
|
||||
|
||||
charset = list(range(10)) + list("abcdefghijklmnopqrstuvwxyz") + list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
def randomstring(length=32):
|
||||
|
@ -30,7 +30,6 @@ dependencies = [
|
||||
"sqlalchemy==2.0",
|
||||
"python-datauri==3.0.*",
|
||||
"requests==2.32.*",
|
||||
"setuptools==75.8.*",
|
||||
"toml==0.10.*",
|
||||
"PyYAML==6.0.*"
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user