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]
|
||||
name = "skyeweave"
|
||||
version = "1.0.0-c.1"
|
||||
version = "1.0.0-c.2"
|
||||
requires-python = ">= 3.10"
|
||||
authors = [{name = "Firq", email = "firelp42@gmail.com"}]
|
||||
maintainers = [{name = "Firq", email = "firelp42@gmail.com"}]
|
||||
|
@ -47,11 +47,13 @@ disable = [
|
|||
"missing-class-docstring",
|
||||
"logging-fstring-interpolation",
|
||||
]
|
||||
ignore-paths="test/*"
|
||||
|
||||
[tool.mypy]
|
||||
python_version = "3.11"
|
||||
warn_return_any = true
|
||||
warn_unused_configs = true
|
||||
exclude = [ "test" ]
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools >= 61.0"]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import importlib.metadata
|
||||
|
||||
__version__ = importlib.metadata.version(__package__ or "skyeweave")
|
||||
|
||||
from .service import compose
|
||||
|
|
|
@ -5,15 +5,14 @@ import sys
|
|||
from typing import List
|
||||
|
||||
from .. import __version__
|
||||
from ..backend import compose
|
||||
from ..service import compose
|
||||
from ..config import AtlasAPIConfig, LoggingConfig, PathConfig
|
||||
from ..utils.filesystem import rmdir
|
||||
from ..utils.disables import disable_tqdm
|
||||
from ..utils import rmdir, disable_tqdm
|
||||
|
||||
LOGGER = logging.getLogger(LoggingConfig.NAME)
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
class Arguments(argparse.Namespace):
|
||||
class CLIArguments(argparse.Namespace):
|
||||
"""
|
||||
Default Arguments when calling the CLI
|
||||
"""
|
||||
|
@ -25,7 +24,7 @@ class Arguments(argparse.Namespace):
|
|||
timeout: int
|
||||
quiet: bool
|
||||
|
||||
def parse_arguments():
|
||||
def parse_arguments(arguments):
|
||||
"""
|
||||
Create a parser and parse the arguments of sys.argv based on the Arguments Namespace
|
||||
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("--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()
|
||||
args, extra_args = parser.parse_known_args(sys.argv[1:], namespace=args)
|
||||
return args, extra_args
|
||||
|
||||
def welcome():
|
||||
def __welcome():
|
||||
print("-------------------------------------------")
|
||||
print(" Welcome to skyeweave, an expression sheet ")
|
||||
print(" composer developed by Firq ")
|
||||
|
@ -68,18 +64,16 @@ def validate_id(input_id: None | str) -> int:
|
|||
return int(input_id)
|
||||
|
||||
def run():
|
||||
args, _ = parse_arguments()
|
||||
args, _ = parse_arguments(sys.argv[1:])
|
||||
if args.output:
|
||||
PathConfig.OUTPUT = pathlib.Path(args.output)
|
||||
|
||||
if args.timeout and args.timeout >= 0:
|
||||
AtlasAPIConfig.TIMEOUT = args.timeout
|
||||
|
||||
if args.quiet:
|
||||
disable_tqdm()
|
||||
LOGGER.disabled = True
|
||||
else:
|
||||
welcome()
|
||||
__welcome()
|
||||
|
||||
input_id = validate_id(args.id)
|
||||
|
||||
|
@ -93,8 +87,7 @@ def run():
|
|||
else:
|
||||
LOGGER.info("No cache to clear was found, continuing")
|
||||
|
||||
if args.reset:
|
||||
if PathConfig.IMAGES.exists():
|
||||
if args.reset and PathConfig.IMAGES.exists():
|
||||
rmdir(PathConfig.IMAGES)
|
||||
LOGGER.info("Successfully reset local storage")
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
from .logger import init_logger
|
||||
LOGGER = init_logger()
|
||||
from .filesystem import rmdir
|
||||
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 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":
|
||||
disable_tqdm()
|
||||
|
||||
logger = logging.getLogger(LoggingConfig.NAME)
|
||||
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)
|
||||
default_logger = logging.getLogger(LoggingConfig.NAME)
|
||||
default_logger.setLevel(LoggingConfig.LEVEL)
|
||||
|
||||
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