new exports and restructuring
This commit is contained in:
parent
926aa582dc
commit
43d21deeed
9 changed files with 38 additions and 37 deletions
|
@ -1,6 +1,6 @@
|
||||||
[project]
|
[project]
|
||||||
name = "skyeweave"
|
name = "skyeweave"
|
||||||
version = "1.0.0-c.1"
|
version = "1.0.0-c.2"
|
||||||
requires-python = ">= 3.10"
|
requires-python = ">= 3.10"
|
||||||
authors = [{name = "Firq", email = "firelp42@gmail.com"}]
|
authors = [{name = "Firq", email = "firelp42@gmail.com"}]
|
||||||
maintainers = [{name = "Firq", email = "firelp42@gmail.com"}]
|
maintainers = [{name = "Firq", email = "firelp42@gmail.com"}]
|
||||||
|
@ -47,11 +47,13 @@ disable = [
|
||||||
"missing-class-docstring",
|
"missing-class-docstring",
|
||||||
"logging-fstring-interpolation",
|
"logging-fstring-interpolation",
|
||||||
]
|
]
|
||||||
|
ignore-paths="test/*"
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
python_version = "3.11"
|
python_version = "3.11"
|
||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unused_configs = true
|
warn_unused_configs = true
|
||||||
|
exclude = [ "test" ]
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["setuptools >= 61.0"]
|
requires = ["setuptools >= 61.0"]
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
import importlib.metadata
|
import importlib.metadata
|
||||||
|
|
||||||
__version__ = importlib.metadata.version(__package__ or "skyeweave")
|
__version__ = importlib.metadata.version(__package__ or "skyeweave")
|
||||||
|
|
||||||
|
from .service import compose
|
||||||
|
|
|
@ -5,15 +5,14 @@ import sys
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from .. import __version__
|
from .. import __version__
|
||||||
from ..backend import compose
|
from ..service import compose
|
||||||
from ..config import AtlasAPIConfig, LoggingConfig, PathConfig
|
from ..config import AtlasAPIConfig, LoggingConfig, PathConfig
|
||||||
from ..utils.filesystem import rmdir
|
from ..utils import rmdir, disable_tqdm
|
||||||
from ..utils.disables import disable_tqdm
|
|
||||||
|
|
||||||
LOGGER = logging.getLogger(LoggingConfig.NAME)
|
LOGGER = logging.getLogger(LoggingConfig.NAME)
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class Arguments(argparse.Namespace):
|
class CLIArguments(argparse.Namespace):
|
||||||
"""
|
"""
|
||||||
Default Arguments when calling the CLI
|
Default Arguments when calling the CLI
|
||||||
"""
|
"""
|
||||||
|
@ -25,7 +24,7 @@ class Arguments(argparse.Namespace):
|
||||||
timeout: int
|
timeout: int
|
||||||
quiet: bool
|
quiet: bool
|
||||||
|
|
||||||
def parse_arguments():
|
def parse_arguments(arguments):
|
||||||
"""
|
"""
|
||||||
Create a parser and parse the arguments of sys.argv based on the Arguments Namespace
|
Create a parser and parse the arguments of sys.argv based on the Arguments Namespace
|
||||||
Returns arguments and extra arguments separately
|
Returns arguments and extra arguments separately
|
||||||
|
@ -44,12 +43,9 @@ def parse_arguments():
|
||||||
parser.add_argument("--reset", action="store_true", default=False, dest="reset", help="Delete any already downloaded assets")
|
parser.add_argument("--reset", action="store_true", default=False, dest="reset", help="Delete any already downloaded assets")
|
||||||
parser.add_argument("--quiet", "-q", action="store_true", default=False, dest="quiet", help="Mute output and hide progress bars")
|
parser.add_argument("--quiet", "-q", action="store_true", default=False, dest="quiet", help="Mute output and hide progress bars")
|
||||||
|
|
||||||
|
return parser.parse_known_args(arguments, namespace=CLIArguments)
|
||||||
|
|
||||||
args = Arguments()
|
def __welcome():
|
||||||
args, extra_args = parser.parse_known_args(sys.argv[1:], namespace=args)
|
|
||||||
return args, extra_args
|
|
||||||
|
|
||||||
def welcome():
|
|
||||||
print("-------------------------------------------")
|
print("-------------------------------------------")
|
||||||
print(" Welcome to skyeweave, an expression sheet ")
|
print(" Welcome to skyeweave, an expression sheet ")
|
||||||
print(" composer developed by Firq ")
|
print(" composer developed by Firq ")
|
||||||
|
@ -68,18 +64,16 @@ def validate_id(input_id: None | str) -> int:
|
||||||
return int(input_id)
|
return int(input_id)
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
args, _ = parse_arguments()
|
args, _ = parse_arguments(sys.argv[1:])
|
||||||
if args.output:
|
if args.output:
|
||||||
PathConfig.OUTPUT = pathlib.Path(args.output)
|
PathConfig.OUTPUT = pathlib.Path(args.output)
|
||||||
|
|
||||||
if args.timeout and args.timeout >= 0:
|
if args.timeout and args.timeout >= 0:
|
||||||
AtlasAPIConfig.TIMEOUT = args.timeout
|
AtlasAPIConfig.TIMEOUT = args.timeout
|
||||||
|
|
||||||
if args.quiet:
|
if args.quiet:
|
||||||
disable_tqdm()
|
disable_tqdm()
|
||||||
LOGGER.disabled = True
|
LOGGER.disabled = True
|
||||||
else:
|
else:
|
||||||
welcome()
|
__welcome()
|
||||||
|
|
||||||
input_id = validate_id(args.id)
|
input_id = validate_id(args.id)
|
||||||
|
|
||||||
|
@ -93,9 +87,8 @@ def run():
|
||||||
else:
|
else:
|
||||||
LOGGER.info("No cache to clear was found, continuing")
|
LOGGER.info("No cache to clear was found, continuing")
|
||||||
|
|
||||||
if args.reset:
|
if args.reset and PathConfig.IMAGES.exists():
|
||||||
if PathConfig.IMAGES.exists():
|
rmdir(PathConfig.IMAGES)
|
||||||
rmdir(PathConfig.IMAGES)
|
LOGGER.info("Successfully reset local storage")
|
||||||
LOGGER.info("Successfully reset local storage")
|
|
||||||
|
|
||||||
compose(input_id, args.filter)
|
compose(input_id, args.filter)
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
from .logger import init_logger
|
from .filesystem import rmdir
|
||||||
LOGGER = init_logger()
|
from .logger import LOGGER, disable_tqdm
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
# pylint: disable=import-outside-toplevel
|
|
||||||
def disable_tqdm():
|
|
||||||
from tqdm import tqdm
|
|
||||||
from functools import partialmethod
|
|
||||||
tqdm.__init__ = partialmethod(tqdm.__init__, disable=True)
|
|
|
@ -1,18 +1,27 @@
|
||||||
|
# pylint: disable=import-outside-toplevel
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
from ..config import LoggingConfig
|
|
||||||
from .disables import disable_tqdm
|
|
||||||
|
|
||||||
def init_logger():
|
from ..config import LoggingConfig
|
||||||
|
|
||||||
|
def disable_tqdm():
|
||||||
|
from tqdm import tqdm
|
||||||
|
from functools import partialmethod
|
||||||
|
tqdm.__init__ = partialmethod(tqdm.__init__, disable=True)
|
||||||
|
|
||||||
|
def __init_logger():
|
||||||
if LoggingConfig.LEVEL == "DEBUG":
|
if LoggingConfig.LEVEL == "DEBUG":
|
||||||
disable_tqdm()
|
disable_tqdm()
|
||||||
|
|
||||||
logger = logging.getLogger(LoggingConfig.NAME)
|
default_logger = logging.getLogger(LoggingConfig.NAME)
|
||||||
logger.setLevel(LoggingConfig.LEVEL)
|
default_logger.setLevel(LoggingConfig.LEVEL)
|
||||||
handler = logging.StreamHandler(stream=sys.stdout)
|
|
||||||
formatter = logging.Formatter('[%(levelname)s] [%(name)s] %(message)s')
|
|
||||||
handler.setFormatter(formatter)
|
|
||||||
logger.addHandler(handler)
|
|
||||||
|
|
||||||
return logger
|
default_handler = logging.StreamHandler(stream=sys.stdout)
|
||||||
|
default_formatter = logging.Formatter('[%(levelname)s] [%(name)s] %(message)s')
|
||||||
|
|
||||||
|
default_handler.setFormatter(default_formatter)
|
||||||
|
default_logger.addHandler(default_handler)
|
||||||
|
|
||||||
|
return default_logger
|
||||||
|
|
||||||
|
LOGGER = __init_logger()
|
||||||
|
|
Loading…
Reference in a new issue