wizlib 0.8.4__py3-none-any.whl → 0.9.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of wizlib might be problematic. Click here for more details.
- wizlib/command_handler.py +17 -6
- wizlib/config_machine.py +15 -1
- {wizlib-0.8.4.dist-info → wizlib-0.9.3.dist-info}/METADATA +2 -2
- wizlib-0.9.3.dist-info/RECORD +10 -0
- {wizlib-0.8.4.dist-info → wizlib-0.9.3.dist-info}/WHEEL +1 -1
- wizlib-0.8.4.dist-info/RECORD +0 -10
- {wizlib-0.8.4.dist-info → wizlib-0.9.3.dist-info}/top_level.txt +0 -0
wizlib/command_handler.py
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import sys
|
|
2
2
|
from argparse import ArgumentError, ArgumentParser
|
|
3
3
|
from dataclasses import dataclass
|
|
4
|
+
import os
|
|
4
5
|
|
|
5
6
|
from wizlib.class_family import ClassFamily
|
|
6
7
|
from wizlib.super_wrapper import SuperWrapper
|
|
7
8
|
|
|
8
9
|
|
|
10
|
+
RED = '\033[91m'
|
|
11
|
+
RESET = '\033[0m'
|
|
12
|
+
|
|
13
|
+
|
|
9
14
|
class CommandHandler:
|
|
10
15
|
"""Handle commands from a ClassFamily"""
|
|
11
16
|
|
|
12
17
|
def __init__(self, atriarch):
|
|
13
18
|
"""Pass in the command base class, the atriarch of a
|
|
14
19
|
classfamily that meeting the CommandHandler spec"""
|
|
15
|
-
self.parser = ArgumentParser(prog=atriarch.
|
|
20
|
+
self.parser = ArgumentParser(prog=atriarch.appname,
|
|
16
21
|
exit_on_error=False)
|
|
17
22
|
atriarch.add_app_args(self.parser)
|
|
18
23
|
subparsers = self.parser.add_subparsers(dest='command')
|
|
@@ -49,11 +54,17 @@ class CommandHandler:
|
|
|
49
54
|
@classmethod
|
|
50
55
|
def shell(cls, atriarch):
|
|
51
56
|
"""Call this from a shell/main entrypoint"""
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
try:
|
|
58
|
+
result, status = cls(atriarch).handle(sys.argv[1:])
|
|
59
|
+
if result:
|
|
60
|
+
print(result)
|
|
61
|
+
if status:
|
|
62
|
+
print(status)
|
|
63
|
+
except Exception as error:
|
|
64
|
+
if os.getenv('DEBUG'):
|
|
65
|
+
raise error
|
|
66
|
+
else:
|
|
67
|
+
print(f"\n{RED}{type(error).__name__}: {error}{RESET}\n")
|
|
57
68
|
|
|
58
69
|
|
|
59
70
|
@dataclass
|
wizlib/config_machine.py
CHANGED
|
@@ -2,6 +2,7 @@ from argparse import Namespace
|
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
import os
|
|
4
4
|
from dataclasses import dataclass
|
|
5
|
+
from unittest.mock import patch
|
|
5
6
|
|
|
6
7
|
from yaml import load
|
|
7
8
|
from yaml import Loader
|
|
@@ -22,7 +23,7 @@ class ConfigMachine:
|
|
|
22
23
|
config - Path to a config file. Meant to be populated in the init method.
|
|
23
24
|
"""
|
|
24
25
|
|
|
25
|
-
appname
|
|
26
|
+
appname = ''
|
|
26
27
|
config: str = None
|
|
27
28
|
|
|
28
29
|
@property
|
|
@@ -67,3 +68,16 @@ class ConfigMachine:
|
|
|
67
68
|
"""Allows a Command class to also inherit from ConfigMachine. List
|
|
68
69
|
ConfigMachine first."""
|
|
69
70
|
parser.add_argument('--config', action='store')
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def nohome_test(): # pragma: nocover
|
|
74
|
+
"""Fake out a ConfigMachine so that it thinks test/files is the home
|
|
75
|
+
directory. This way it's not tempted to pull real configuration."""
|
|
76
|
+
return patch('pathlib.Path.home', lambda: Path('test/files'))
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def patchconfig_test(**kwargs): # pragma: nocover
|
|
80
|
+
"""Hand testable config data to a test method. First pass: always return
|
|
81
|
+
None."""
|
|
82
|
+
methodpath = 'wizlib.config_machine.ConfigMachine.config_get'
|
|
83
|
+
return patch(methodpath, lambda s, t: True)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: wizlib
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.3
|
|
4
4
|
Summary: A collection of Python modules that are useful across multiple projects
|
|
5
5
|
Author-email: Francis Potter <wizlib@steampunkwizard.ca>
|
|
6
6
|
License: MIT
|
|
7
7
|
Requires-Python: >=3.8
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
|
-
Requires-Dist: PyYAML
|
|
9
|
+
Requires-Dist: PyYAML >=6.0.1
|
|
10
10
|
Requires-Dist: gnureadline ; platform_system == "Darwin"
|
|
11
11
|
Requires-Dist: pyreadline3 ; platform_system == "Windows"
|
|
12
12
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
wizlib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
wizlib/class_family.py,sha256=IBdHPXouJDgxu3nOFE48QlRHYFyTGhTk_HbfnNTK-m8,4413
|
|
3
|
+
wizlib/command_handler.py,sha256=3NKXfkH-orBm8G-KCVLPW1YuvtHC59lLYMyaK8VVwg4,3033
|
|
4
|
+
wizlib/config_machine.py,sha256=OUGXx_ixAMmfQGlaxg7R7a6IRKK1qK5qX16ZOhLAMbQ,2819
|
|
5
|
+
wizlib/rlinput.py,sha256=l00Pa3rxNeY6LJgz8Aws_rTKoEchw33fuL8yqHF9_-o,1754
|
|
6
|
+
wizlib/super_wrapper.py,sha256=F834ytHqA7zegTD1ezk_uxlF9PLygh84wReuiqcI7BI,272
|
|
7
|
+
wizlib-0.9.3.dist-info/METADATA,sha256=iql89LJy4DT8bw2ijjeScXAfbl1hjsF-cyZhFQRFEsk,5529
|
|
8
|
+
wizlib-0.9.3.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
9
|
+
wizlib-0.9.3.dist-info/top_level.txt,sha256=PhxyT43KqCsarAe-YroORUZRMTLA-zwTAaADXKjNcB4,7
|
|
10
|
+
wizlib-0.9.3.dist-info/RECORD,,
|
wizlib-0.8.4.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
wizlib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
wizlib/class_family.py,sha256=IBdHPXouJDgxu3nOFE48QlRHYFyTGhTk_HbfnNTK-m8,4413
|
|
3
|
-
wizlib/command_handler.py,sha256=Yk2-MjR8g3qhkV7knBCPn-mZnyGDLHQxa5kvHi-w3TE,2764
|
|
4
|
-
wizlib/config_machine.py,sha256=-FEoKdhbRA8m2TJC0Nile5kzoZ_xd_sptu3TTlNcfC0,2284
|
|
5
|
-
wizlib/rlinput.py,sha256=l00Pa3rxNeY6LJgz8Aws_rTKoEchw33fuL8yqHF9_-o,1754
|
|
6
|
-
wizlib/super_wrapper.py,sha256=F834ytHqA7zegTD1ezk_uxlF9PLygh84wReuiqcI7BI,272
|
|
7
|
-
wizlib-0.8.4.dist-info/METADATA,sha256=DaBxBpio0uSw-cjdcGsBbKxZcTknvlsPU81P6xsm6HU,5531
|
|
8
|
-
wizlib-0.8.4.dist-info/WHEEL,sha256=AtBG6SXL3KF_v0NxLf0ehyVOh0cold-JbJYXNGorC6Q,92
|
|
9
|
-
wizlib-0.8.4.dist-info/top_level.txt,sha256=PhxyT43KqCsarAe-YroORUZRMTLA-zwTAaADXKjNcB4,7
|
|
10
|
-
wizlib-0.8.4.dist-info/RECORD,,
|
|
File without changes
|