From 87b262ebeeacaf6f8d1c1b92d3e57790de5d1327 Mon Sep 17 00:00:00 2001 From: miruka Date: Wed, 18 Dec 2019 06:55:05 -0400 Subject: [PATCH] Move backend.__about__ stuff into __init__ --- src/backend/__about__.py | 12 ------------ src/backend/__init__.py | 4 +++- src/backend/backend.py | 4 ++-- src/backend/matrix_client.py | 10 +++++----- src/gui/PythonBridge/PythonBridge.qml | 2 +- src/main.cpp | 2 +- 6 files changed, 12 insertions(+), 22 deletions(-) delete mode 100644 src/backend/__about__.py diff --git a/src/backend/__about__.py b/src/backend/__about__.py deleted file mode 100644 index 5ec94a40..00000000 --- a/src/backend/__about__.py +++ /dev/null @@ -1,12 +0,0 @@ -"""""" - -__pkg_name__ = "harmonyqml" -__pretty_name__ = "Harmony QML" -__version__ = "0.2.3" -__status__ = "Development" -# __status__ = "Production" - -__author__ = "miruka" -__email__ = "miruka@disroot.org" - -__license__ = "LGPLv3" diff --git a/src/backend/__init__.py b/src/backend/__init__.py index 2c631a9e..3c1062e6 100644 --- a/src/backend/__init__.py +++ b/src/backend/__init__.py @@ -1 +1,3 @@ -from .qml_bridge import BRIDGE # noqa +__app_name__ = "harmonyqml" +__display_name__ = "Harmony QML" +__version__ = "0.3.0" diff --git a/src/backend/backend.py b/src/backend/backend.py index 0656aca4..524e927f 100644 --- a/src/backend/backend.py +++ b/src/backend/backend.py @@ -9,7 +9,7 @@ from appdirs import AppDirs import nio -from . import __about__ +from . import __app_name__ from .errors import MatrixError from .matrix_client import MatrixClient from .models.items import Account, Device, Event, Member, Room, Upload @@ -22,7 +22,7 @@ nio.log.logbook.StreamHandler(sys.stderr).push_application() class Backend: def __init__(self) -> None: - self.appdirs = AppDirs(appname=__about__.__pkg_name__, roaming=True) + self.appdirs = AppDirs(appname=__app_name__, roaming=True) from . import config_files self.saved_accounts = config_files.Accounts(self) diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index 3450c648..82fd9416 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -24,7 +24,7 @@ import nio from nio.crypto import AsyncDataT as UploadData from nio.crypto import async_generator_from_data -from .__about__ import __pkg_name__, __pretty_name__ +from . import __app_name__, __display_name__ from . import utils from .errors import ( BadMimeType, InvalidUserId, InvalidUserInContext, MatrixError, @@ -114,7 +114,7 @@ class MatrixClient(nio.AsyncClient): def default_device_name(self) -> str: os_ = f" on {platform.system()}".rstrip() os_ = f"{os_} {platform.release()}".rstrip() if os_ != " on" else "" - return f"{__pretty_name__}{os_}" + return f"{__display_name__}{os_}" async def login(self, password: str, device_name: str = "") -> None: @@ -221,7 +221,7 @@ class MatrixClient(nio.AsyncClient): # to the sender so our other accounts wouldn't be able to replace # local echoes by real messages. tx_id = uuid4() - content[f"{__pkg_name__}.transaction_id"] = str(tx_id) + content[f"{__app_name__}.transaction_id"] = str(tx_id) await self._local_echo(room_id, tx_id, event_type, content=echo_body) await self._send_message(room_id, content) @@ -291,7 +291,7 @@ class MatrixClient(nio.AsyncClient): thumb_info: Optional[MatrixImageInfo] = None content: dict = { - f"{__pkg_name__}.transaction_id": str(transaction_id), + f"{__app_name__}.transaction_id": str(transaction_id), "body": path.name, "info": { @@ -926,7 +926,7 @@ class MatrixClient(nio.AsyncClient): # Add the Event to model tx_id = ev.source.get("content", {}).get( - f"{__pkg_name__}.transaction_id", + f"{__app_name__}.transaction_id", ) local_sender = ev.sender in self.backend.clients diff --git a/src/gui/PythonBridge/PythonBridge.qml b/src/gui/PythonBridge/PythonBridge.qml index ee815079..f8f7ae74 100644 --- a/src/gui/PythonBridge/PythonBridge.qml +++ b/src/gui/PythonBridge/PythonBridge.qml @@ -12,7 +12,7 @@ Python { addImportPath("src") addImportPath("qrc:/src") - importNames("backend", ["BRIDGE"], () => { + importNames("backend.qml_bridge", ["BRIDGE"], () => { loadSettings(() => { callCoro("saved_accounts.any_saved", [], any => { if (any) { py.callCoro("load_saved_accounts", []) } diff --git a/src/main.cpp b/src/main.cpp index a25613f9..118b476f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) { QApplication::setOrganizationName("harmonyqml"); QApplication::setApplicationName("harmonyqml"); QApplication::setApplicationDisplayName("HarmonyQML"); - QApplication::setApplicationVersion("0.2.3"); + QApplication::setApplicationVersion("0.3.0"); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication app(argc, argv);