From 8a4086bf98ea4e759ca9576f20c74cee6ced99a9 Mon Sep 17 00:00:00 2001 From: cibere <71997063+cibere@users.noreply.github.com> Date: Sun, 27 Oct 2024 11:56:05 -0700 Subject: [PATCH] run formatters --- WordnikDictionary/core.py | 5 ++-- WordnikDictionary/errors.py | 36 +++++++++++++++++++++----- WordnikDictionary/options.py | 6 ++--- WordnikDictionary/utils.py | 2 +- WordnikDictionary/word_relationship.py | 1 - 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/WordnikDictionary/core.py b/WordnikDictionary/core.py index f793615..c2271a4 100644 --- a/WordnikDictionary/core.py +++ b/WordnikDictionary/core.py @@ -1,6 +1,7 @@ import inspect import json -import re, os +import os +import re import sys import webbrowser from logging import getLogger @@ -181,4 +182,4 @@ def change_query(self, query: str): FlowLauncherAPI.change_query(query) def open_log_file_folder(self): - os.system(f"explorer.exe /select, \"wordnik.logs\"") \ No newline at end of file + os.system(f'explorer.exe /select, "wordnik.logs"') diff --git a/WordnikDictionary/errors.py b/WordnikDictionary/errors.py index 80a4b2d..3895808 100644 --- a/WordnikDictionary/errors.py +++ b/WordnikDictionary/errors.py @@ -2,7 +2,8 @@ from .options import Option -__all__ = ("PluginException","InternalException") +__all__ = ("PluginException", "InternalException") + class BaseException(Exception): options: list[Option] @@ -13,6 +14,7 @@ def __init__(self, text: str, options: list[Option]) -> None: for opt in options: opt.icon = "error" + class PluginException(BaseException): @classmethod def create( @@ -36,10 +38,32 @@ def wnf(cls: type[PluginException]) -> PluginException: class InternalException(BaseException): def __init__(self) -> None: - opts= [ + opts = [ Option(score=100, icon="error", title="An internal error has occured."), - Option(score=80, icon="github", title="Please open a github issue", sub="Click this to open github repository", callback="open_url", params=["https://github.com/cibere/Flow.Launcher.Plugin.WordNikDictionary"]), - Option(score=79, icon="discord", title="Or create a thread in our discord server", sub='Click on this to open discord invite', callback="open_url", params=['https://discord.gg/y4STfDvc8j']), - Option(score=0, icon="log_file", title="And provide your log file (wordnik.log)", sub="Click on this to open plugin folder.", callback="open_log_file_folder") + Option( + score=80, + icon="github", + title="Please open a github issue", + sub="Click this to open github repository", + callback="open_url", + params=[ + "https://github.com/cibere/Flow.Launcher.Plugin.WordNikDictionary" + ], + ), + Option( + score=79, + icon="discord", + title="Or create a thread in our discord server", + sub="Click on this to open discord invite", + callback="open_url", + params=["https://discord.gg/y4STfDvc8j"], + ), + Option( + score=0, + icon="log_file", + title="And provide your log file (wordnik.log)", + sub="Click on this to open plugin folder.", + callback="open_log_file_folder", + ), ] - super().__init__("An Interal Error has occured.", opts) \ No newline at end of file + super().__init__("An Interal Error has occured.", opts) diff --git a/WordnikDictionary/options.py b/WordnikDictionary/options.py index dacc195..f180768 100644 --- a/WordnikDictionary/options.py +++ b/WordnikDictionary/options.py @@ -16,7 +16,7 @@ def __init__( context_data: list[Option] = [], hide_after_callback: bool = True, score: int = 0, - icon: str = "app" + icon: str = "app", ): self.title = title self.icon_name = icon @@ -30,7 +30,7 @@ def __init__( @property def icon(self) -> str: return f"Images/{self.icon_name}.png" - + @icon.setter def icon(self, name: str) -> None: self.icon_name = name @@ -41,7 +41,7 @@ def to_jsonrpc(self) -> dict: "SubTitle": self.sub, "IcoPath": self.icon, "ContextData": [opt.to_jsonrpc() for opt in self.context_data], - "score": self.score + "score": self.score, } if self.callback: data["JsonRPCAction"] = { diff --git a/WordnikDictionary/utils.py b/WordnikDictionary/utils.py index cc82a28..890f8f1 100644 --- a/WordnikDictionary/utils.py +++ b/WordnikDictionary/utils.py @@ -45,7 +45,7 @@ def inner(*args, **kwargs): def setup_logging() -> None: level = logging.DEBUG handler = logging.handlers.RotatingFileHandler("wordnik.logs", maxBytes=1000000) - + dt_fmt = "%Y-%m-%d %H:%M:%S" formatter = logging.Formatter( "[{asctime}] [{levelname:<8}] {name}: {message}", dt_fmt, style="{" diff --git a/WordnikDictionary/word_relationship.py b/WordnikDictionary/word_relationship.py index f55bc9a..37d8f9d 100644 --- a/WordnikDictionary/word_relationship.py +++ b/WordnikDictionary/word_relationship.py @@ -1,6 +1,5 @@ from __future__ import annotations - from .dataclass import Dataclass from .options import Option