mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Replaced pkg_resources with importlib
This commit is contained in:
parent
36b47368a3
commit
4dd7cf69a7
@ -2,7 +2,6 @@ import re
|
|||||||
#from . import utilities
|
#from . import utilities
|
||||||
from doreah import tsv
|
from doreah import tsv
|
||||||
from .globalconf import data_dir, malojaconfig
|
from .globalconf import data_dir, malojaconfig
|
||||||
import pkg_resources
|
|
||||||
|
|
||||||
# need to do this as a class so it can retain loaded settings from file
|
# need to do this as a class so it can retain loaded settings from file
|
||||||
# apparently this is not true
|
# apparently this is not true
|
||||||
|
@ -39,7 +39,6 @@ import yaml, json
|
|||||||
import math
|
import math
|
||||||
|
|
||||||
# url handling
|
# url handling
|
||||||
from importlib.machinery import SourceFileLoader
|
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import pkg_resources
|
from importlib import resources
|
||||||
from distutils import dir_util
|
from distutils import dir_util
|
||||||
from doreah.io import col, ask, prompt
|
from doreah.io import col, ask, prompt
|
||||||
from doreah import auth
|
from doreah import auth
|
||||||
@ -19,7 +19,7 @@ ext_apikeys = [
|
|||||||
|
|
||||||
|
|
||||||
def copy_initial_local_files():
|
def copy_initial_local_files():
|
||||||
folder = pkg_resources.resource_filename("maloja","data_files")
|
with resources.files("maloja") / 'data_files' as folder:
|
||||||
for cat in dir_settings:
|
for cat in dir_settings:
|
||||||
dir_util.copy_tree(os.path.join(folder,cat),dir_settings[cat],update=False)
|
dir_util.copy_tree(os.path.join(folder,cat),dir_settings[cat],update=False)
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import sys
|
|||||||
import os
|
import os
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
import setproctitle
|
import setproctitle
|
||||||
import pkg_resources
|
from importlib import resources
|
||||||
from css_html_js_minify import html_minify, css_minify
|
from css_html_js_minify import html_minify, css_minify
|
||||||
import datauri
|
import datauri
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ HOST = malojaconfig["HOST"]
|
|||||||
THREADS = 24
|
THREADS = 24
|
||||||
BaseRequest.MEMFILE_MAX = 15 * 1024 * 1024
|
BaseRequest.MEMFILE_MAX = 15 * 1024 * 1024
|
||||||
|
|
||||||
STATICFOLDER = pkg_resources.resource_filename(__name__,"web/static")
|
#STATICFOLDER = importlib.resources.path(__name__,"web/static")
|
||||||
|
|
||||||
webserver = Bottle()
|
webserver = Bottle()
|
||||||
|
|
||||||
@ -53,8 +53,10 @@ setproctitle.setproctitle("Maloja")
|
|||||||
|
|
||||||
def generate_css():
|
def generate_css():
|
||||||
cssstr = ""
|
cssstr = ""
|
||||||
for file in os.listdir(os.path.join(STATICFOLDER,"css")):
|
with resources.files('maloja') / 'web' / 'static' as staticfolder:
|
||||||
with open(os.path.join(STATICFOLDER,"css",file),"r") as filed:
|
|
||||||
|
for file in os.listdir(os.path.join(staticfolder,"css")):
|
||||||
|
with open(os.path.join(staticfolder,"css",file),"r") as filed:
|
||||||
cssstr += filed.read()
|
cssstr += filed.read()
|
||||||
|
|
||||||
for file in os.listdir(data_dir['css']()):
|
for file in os.listdir(data_dir['css']()):
|
||||||
@ -216,7 +218,8 @@ def login():
|
|||||||
@webserver.route("/media/<name>.<ext>")
|
@webserver.route("/media/<name>.<ext>")
|
||||||
def static(name,ext):
|
def static(name,ext):
|
||||||
assert ext in ["txt","ico","jpeg","jpg","png","less","js","ttf"]
|
assert ext in ["txt","ico","jpeg","jpg","png","less","js","ttf"]
|
||||||
response = static_file(ext + "/" + name + "." + ext,root=STATICFOLDER)
|
with resources.files('maloja') / 'web' / 'static' as staticfolder:
|
||||||
|
response = static_file(ext + "/" + name + "." + ext,root=staticfolder)
|
||||||
response.set_header("Cache-Control", "public, max-age=3600")
|
response.set_header("Cache-Control", "public, max-age=3600")
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user