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 doreah import tsv
|
||||
from .globalconf import data_dir, malojaconfig
|
||||
import pkg_resources
|
||||
|
||||
# need to do this as a class so it can retain loaded settings from file
|
||||
# apparently this is not true
|
||||
|
@ -39,7 +39,6 @@ import yaml, json
|
||||
import math
|
||||
|
||||
# url handling
|
||||
from importlib.machinery import SourceFileLoader
|
||||
import urllib
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import pkg_resources
|
||||
from importlib import resources
|
||||
from distutils import dir_util
|
||||
from doreah.io import col, ask, prompt
|
||||
from doreah import auth
|
||||
@ -19,9 +19,9 @@ ext_apikeys = [
|
||||
|
||||
|
||||
def copy_initial_local_files():
|
||||
folder = pkg_resources.resource_filename("maloja","data_files")
|
||||
for cat in dir_settings:
|
||||
dir_util.copy_tree(os.path.join(folder,cat),dir_settings[cat],update=False)
|
||||
with resources.files("maloja") / 'data_files' as folder:
|
||||
for cat in dir_settings:
|
||||
dir_util.copy_tree(os.path.join(folder,cat),dir_settings[cat],update=False)
|
||||
|
||||
charset = list(range(10)) + list("abcdefghijklmnopqrstuvwxyz") + list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
def randomstring(length=32):
|
||||
|
@ -3,7 +3,7 @@ import sys
|
||||
import os
|
||||
from threading import Thread
|
||||
import setproctitle
|
||||
import pkg_resources
|
||||
from importlib import resources
|
||||
from css_html_js_minify import html_minify, css_minify
|
||||
import datauri
|
||||
|
||||
@ -38,7 +38,7 @@ HOST = malojaconfig["HOST"]
|
||||
THREADS = 24
|
||||
BaseRequest.MEMFILE_MAX = 15 * 1024 * 1024
|
||||
|
||||
STATICFOLDER = pkg_resources.resource_filename(__name__,"web/static")
|
||||
#STATICFOLDER = importlib.resources.path(__name__,"web/static")
|
||||
|
||||
webserver = Bottle()
|
||||
|
||||
@ -53,9 +53,11 @@ setproctitle.setproctitle("Maloja")
|
||||
|
||||
def generate_css():
|
||||
cssstr = ""
|
||||
for file in os.listdir(os.path.join(STATICFOLDER,"css")):
|
||||
with open(os.path.join(STATICFOLDER,"css",file),"r") as filed:
|
||||
cssstr += filed.read()
|
||||
with resources.files('maloja') / 'web' / 'static' as staticfolder:
|
||||
|
||||
for file in os.listdir(os.path.join(staticfolder,"css")):
|
||||
with open(os.path.join(staticfolder,"css",file),"r") as filed:
|
||||
cssstr += filed.read()
|
||||
|
||||
for file in os.listdir(data_dir['css']()):
|
||||
if file.endswith(".css"):
|
||||
@ -216,7 +218,8 @@ def login():
|
||||
@webserver.route("/media/<name>.<ext>")
|
||||
def static(name,ext):
|
||||
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")
|
||||
return response
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user