(Added) os paths for the data and the config by default.
Added if config is missing, then the hint shows its path. Updated pyproject.toml information.
This commit is contained in:
@@ -31,3 +31,7 @@
|
|||||||
Updated my name to my fullname and release years.
|
Updated my name to my fullname and release years.
|
||||||
** 1.0.2 <2023-01-15>
|
** 1.0.2 <2023-01-15>
|
||||||
Refactor the database class and remove function for the creating file.
|
Refactor the database class and remove function for the creating file.
|
||||||
|
** 1.1.1 <2023-02-28>
|
||||||
|
Added os paths for the data and the config by default.
|
||||||
|
Added if config is missing, then the hint shows its path.
|
||||||
|
Updated pyproject.toml information.
|
||||||
|
|||||||
+8
-7
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "anitube-simple-notification"
|
name = "anitube-simple-notification"
|
||||||
version = "1.0.0"
|
version = "1.1.1"
|
||||||
authors = [
|
authors = [
|
||||||
{ name="Kostiantyn Klochko", email="kostya_klochko@ukr.net" },
|
{ name="Kostiantyn Klochko", email="kostya_klochko@ukr.net" },
|
||||||
]
|
]
|
||||||
@@ -18,12 +18,13 @@ classifiers = [
|
|||||||
"Operating System :: OS Independent",
|
"Operating System :: OS Independent",
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"requests",
|
"requests~=2.28.2",
|
||||||
"bs4",
|
"beautifulsoup4~=4.11.1",
|
||||||
"notify-py",
|
"notify-py~=0.3.39",
|
||||||
"rich",
|
"rich~=13.1.0",
|
||||||
"tomli",
|
"tomli~=2.0.1",
|
||||||
"loguru"
|
"loguru~=0.5.3",
|
||||||
|
"platformdirs~=3.0.0"
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
|
|||||||
+3
-2
@@ -24,7 +24,7 @@ This module has all for simplify work with the toml configuration file.
|
|||||||
|
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
import tomli
|
import tomli
|
||||||
import os
|
from pathlib import PosixPath
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -70,7 +70,7 @@ class Config:
|
|||||||
del config["URLS"]
|
del config["URLS"]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_config(config_path:str, console:Console) -> dict:
|
def get_config(config_path:PosixPath, console:Console) -> dict:
|
||||||
"""
|
"""
|
||||||
Read the configuration file and return dict as configuration.
|
Read the configuration file and return dict as configuration.
|
||||||
The configuration file must be in the application folder.
|
The configuration file must be in the application folder.
|
||||||
@@ -81,6 +81,7 @@ class Config:
|
|||||||
config = tomli.load(file)
|
config = tomli.load(file)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
console.print(f"[red][ERROR] Please, create configuration file.[/]")
|
console.print(f"[red][ERROR] Please, create configuration file.[/]")
|
||||||
|
console.print(f"[yellow][ERROR] The configuration file path: {config_path}.[/]")
|
||||||
except tomli.TOMLDecodeError:
|
except tomli.TOMLDecodeError:
|
||||||
console.print(f"[red][ERROR] Please, check configuration file for correctness.[/]")
|
console.print(f"[red][ERROR] Please, check configuration file for correctness.[/]")
|
||||||
Config.config_validation_error(config)
|
Config.config_validation_error(config)
|
||||||
|
|||||||
+19
-3
@@ -25,16 +25,32 @@ from rich.console import Console
|
|||||||
from rich.progress import track
|
from rich.progress import track
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
import platformdirs
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# Const sections.
|
# Const sections.
|
||||||
|
|
||||||
# Console initialising
|
# Console initialising
|
||||||
console = Console()
|
console = Console()
|
||||||
|
|
||||||
|
APPNAME = "anitube-simple-notification"
|
||||||
|
APPAUTHOR = "KKlochko"
|
||||||
|
CONFIG_NAME = "config.toml"
|
||||||
BASE_DIR = os.path.dirname(__file__)
|
BASE_DIR = os.path.dirname(__file__)
|
||||||
DB_PATH = os.path.join(BASE_DIR, 'user.db')
|
DATA_DIR = platformdirs.user_data_dir(APPNAME, APPAUTHOR)
|
||||||
POSTERS_PATH = os.path.join(BASE_DIR, 'posters')
|
|
||||||
CONFIG_PATH = os.path.join(BASE_DIR, 'config.toml')
|
DB_PATH = os.path.join(DATA_DIR, 'user.db')
|
||||||
|
POSTERS_PATH = os.path.join(DATA_DIR, 'posters')
|
||||||
|
|
||||||
|
CONFIG_PATH = platformdirs.user_config_path(APPNAME, APPAUTHOR, CONFIG_NAME)
|
||||||
|
|
||||||
|
# check for existing of dirs
|
||||||
|
if not os.path.exists(DATA_DIR):
|
||||||
|
os.makedirs(DATA_DIR)
|
||||||
|
|
||||||
|
if not os.path.exists(CONFIG_PATH):
|
||||||
|
os.makedirs(CONFIG_PATH)
|
||||||
|
|
||||||
config = Config.get_config(CONFIG_PATH, console)
|
config = Config.get_config(CONFIG_PATH, console)
|
||||||
|
|
||||||
# Here you can change testing headers to yours.
|
# Here you can change testing headers to yours.
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ from notifypy import Notify
|
|||||||
class Notification:
|
class Notification:
|
||||||
"""The handler of notification."""
|
"""The handler of notification."""
|
||||||
def __init__(self, title, message, icon_path=""):
|
def __init__(self, title, message, icon_path=""):
|
||||||
"""Initialising the connection information."""
|
"""Initialising the notification information."""
|
||||||
self.title, self.message, self.icon_path = title, message, icon_path
|
self.title, self.message, self.icon_path = title, message, icon_path
|
||||||
|
|
||||||
def send(self):
|
def send(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user