Skip to content

Commit

Permalink
run formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
cibere committed Oct 27, 2024
1 parent a5c9354 commit 8a4086b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 13 deletions.
5 changes: 3 additions & 2 deletions WordnikDictionary/core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import inspect
import json
import re, os
import os
import re
import sys
import webbrowser
from logging import getLogger
Expand Down Expand Up @@ -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\"")
os.system(f'explorer.exe /select, "wordnik.logs"')
36 changes: 30 additions & 6 deletions WordnikDictionary/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from .options import Option

__all__ = ("PluginException","InternalException")
__all__ = ("PluginException", "InternalException")


class BaseException(Exception):
options: list[Option]
Expand All @@ -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(
Expand All @@ -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)
super().__init__("An Interal Error has occured.", opts)
6 changes: 3 additions & 3 deletions WordnikDictionary/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"] = {
Expand Down
2 changes: 1 addition & 1 deletion WordnikDictionary/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="{"
Expand Down
1 change: 0 additions & 1 deletion WordnikDictionary/word_relationship.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations


from .dataclass import Dataclass
from .options import Option

Expand Down

0 comments on commit 8a4086b

Please sign in to comment.