mirror of
https://github.com/maubot/maubot.git
synced 2024-10-01 01:06:10 -04:00
Compare commits
4 Commits
2222f6ce69
...
8b7e091383
Author | SHA1 | Date | |
---|---|---|---|
|
8b7e091383 | ||
|
6e5e40e7e4 | ||
|
61f528d9b3 | ||
|
5ea499430b |
@ -17,7 +17,7 @@ import os
|
|||||||
|
|
||||||
from jinja2 import Template
|
from jinja2 import Template
|
||||||
from packaging.version import Version
|
from packaging.version import Version
|
||||||
from pkg_resources import resource_string
|
import importlib.resources as resources
|
||||||
|
|
||||||
from .. import cliq
|
from .. import cliq
|
||||||
from ..cliq import SPDXValidator, VersionValidator
|
from ..cliq import SPDXValidator, VersionValidator
|
||||||
@ -33,9 +33,9 @@ def load_templates():
|
|||||||
global mod_template, meta_template, base_config, loaded
|
global mod_template, meta_template, base_config, loaded
|
||||||
if loaded:
|
if loaded:
|
||||||
return
|
return
|
||||||
meta_template = Template(resource_string("maubot.cli", "res/maubot.yaml.j2").decode("utf-8"))
|
meta_template = Template(resources.files("maubot.cli").joinpath("res/maubot.yaml.j2").read_text(encoding="utf-8"))
|
||||||
mod_template = Template(resource_string("maubot.cli", "res/plugin.py.j2").decode("utf-8"))
|
mod_template = Template(resources.files("maubot.cli").joinpath("res/plugin.py.j2").read_text(encoding="utf-8"))
|
||||||
base_config = resource_string("maubot.cli", "res/config.yaml").decode("utf-8")
|
base_config = resources.files("maubot.cli").joinpath("res/config.yaml").read_text(encoding="utf-8")
|
||||||
loaded = True
|
loaded = True
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ from __future__ import annotations
|
|||||||
import json
|
import json
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
import pkg_resources
|
import importlib.resources as resources
|
||||||
|
|
||||||
spdx_list: dict[str, dict[str, str]] | None = None
|
spdx_list: dict[str, dict[str, str]] | None = None
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ def load() -> None:
|
|||||||
global spdx_list
|
global spdx_list
|
||||||
if spdx_list is not None:
|
if spdx_list is not None:
|
||||||
return
|
return
|
||||||
with pkg_resources.resource_stream("maubot.cli", "res/spdx.json.zip") as disk_file:
|
with resources.files("maubot.cli").joinpath("res/spdx.json.zip").open("rb") as disk_file:
|
||||||
with zipfile.ZipFile(disk_file) as zip_file:
|
with zipfile.ZipFile(disk_file) as zip_file:
|
||||||
with zip_file.open("spdx.json") as file:
|
with zip_file.open("spdx.json") as file:
|
||||||
spdx_list = json.load(file)
|
spdx_list = json.load(file)
|
||||||
|
@ -23,7 +23,7 @@ import logging
|
|||||||
from aiohttp import hdrs, web
|
from aiohttp import hdrs, web
|
||||||
from aiohttp.abc import AbstractAccessLogger
|
from aiohttp.abc import AbstractAccessLogger
|
||||||
from yarl import URL
|
from yarl import URL
|
||||||
import pkg_resources
|
import importlib.resources as resources
|
||||||
|
|
||||||
from mautrix.api import Method, PathBuilder
|
from mautrix.api import Method, PathBuilder
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ class MaubotServer:
|
|||||||
ui_base = ""
|
ui_base = ""
|
||||||
directory = self.config[
|
directory = self.config[
|
||||||
"server.override_resource_path"
|
"server.override_resource_path"
|
||||||
] or pkg_resources.resource_filename("maubot", "management/frontend/build")
|
] or resources.files("maubot").joinpath("management/frontend/build")
|
||||||
self.app.router.add_static(f"{ui_base}/static", f"{directory}/static")
|
self.app.router.add_static(f"{ui_base}/static", f"{directory}/static")
|
||||||
self.setup_static_root_files(directory, ui_base)
|
self.setup_static_root_files(directory, ui_base)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user