xkits-command 0.3__tar.gz → 0.4.1__tar.gz
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.
- {xkits_command-0.3/xkits_command.egg-info → xkits_command-0.4.1}/PKG-INFO +2 -2
- xkits_command-0.4.1/README.md +3 -0
- {xkits_command-0.3 → xkits_command-0.4.1}/setup.cfg +4 -0
- {xkits_command-0.3 → xkits_command-0.4.1}/setup.py +4 -1
- xkits_command-0.4.1/xargproject/__init__.py +0 -0
- xkits_command-0.4.1/xargproject/command.py +45 -0
- xkits_command-0.4.1/xargproject/project.py +278 -0
- {xkits_command-0.3 → xkits_command-0.4.1}/xkits_command/actuator.py +1 -1
- {xkits_command-0.3 → xkits_command-0.4.1}/xkits_command/attribute.py +1 -1
- {xkits_command-0.3 → xkits_command-0.4.1/xkits_command.egg-info}/PKG-INFO +2 -2
- {xkits_command-0.3 → xkits_command-0.4.1}/xkits_command.egg-info/SOURCES.txt +4 -0
- xkits_command-0.4.1/xkits_command.egg-info/entry_points.txt +2 -0
- {xkits_command-0.3 → xkits_command-0.4.1}/xkits_command.egg-info/top_level.txt +1 -0
- xkits_command-0.3/README.md +0 -3
- {xkits_command-0.3 → xkits_command-0.4.1}/LICENSE +0 -0
- {xkits_command-0.3 → xkits_command-0.4.1}/xkits_command/__init__.py +0 -0
- {xkits_command-0.3 → xkits_command-0.4.1}/xkits_command/parser.py +0 -0
- {xkits_command-0.3 → xkits_command-0.4.1}/xkits_command.egg-info/dependency_links.txt +0 -0
- {xkits_command-0.3 → xkits_command-0.4.1}/xkits_command.egg-info/requires.txt +0 -0
- {xkits_command-0.3 → xkits_command-0.4.1}/xkits_command.egg-info/zip-safe +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: xkits-command
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: Command line module
|
|
5
5
|
Home-page: https://github.com/bondbox/xcommand/
|
|
6
6
|
Author: Mingzhe Zou
|
|
@@ -21,4 +21,4 @@ Requires-Dist: xkits-logger>=0.2
|
|
|
21
21
|
|
|
22
22
|
# xcommand
|
|
23
23
|
|
|
24
|
-
Command line module
|
|
24
|
+
> Command line module
|
|
@@ -45,7 +45,10 @@ setup(
|
|
|
45
45
|
project_urls={"Source Code": __urlcode__,
|
|
46
46
|
"Bug Tracker": __urlbugs__,
|
|
47
47
|
"Documentation": __urldocs__},
|
|
48
|
-
packages=find_packages(
|
|
48
|
+
packages=find_packages(
|
|
49
|
+
include=["xkits_command*", "xargproject*"],
|
|
50
|
+
exclude=["xkits_command.unittest", "xargproject.unittest"]
|
|
51
|
+
),
|
|
49
52
|
install_requires=all_requirements(),
|
|
50
53
|
cmdclass={
|
|
51
54
|
"install": CustomInstallCommand,
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# coding:utf-8
|
|
2
|
+
|
|
3
|
+
from typing import Optional
|
|
4
|
+
from typing import Sequence
|
|
5
|
+
|
|
6
|
+
from xkits_command.actuator import Command
|
|
7
|
+
from xkits_command.actuator import CommandArgument
|
|
8
|
+
from xkits_command.actuator import CommandExecutor
|
|
9
|
+
from xkits_command.attribute import __urlhome__
|
|
10
|
+
from xkits_command.attribute import __version__
|
|
11
|
+
from xkits_command.parser import ArgParser
|
|
12
|
+
|
|
13
|
+
from xargproject.project import Project
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@CommandArgument("init", help="Initialize a command-line project.")
|
|
17
|
+
def add_cmd_init(_arg: ArgParser):
|
|
18
|
+
_arg.add_opt_on("--update", help="allow updating existing files")
|
|
19
|
+
_arg.add_argument("--license", help="select license, default to MIT",
|
|
20
|
+
type=str, metavar="LICENSE", default="MIT",
|
|
21
|
+
choices=["MIT", "GPLv2", "GPLv3"])
|
|
22
|
+
_arg.add_pos("project_name", type=str, metavar="PROJECT")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@CommandExecutor(add_cmd_init)
|
|
26
|
+
def run_cmd_init(cmds: Command) -> int:
|
|
27
|
+
return Project.create(name=cmds.args.project_name,
|
|
28
|
+
license=cmds.args.license,
|
|
29
|
+
allow_update=cmds.args.update)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@CommandArgument("xargproject", description="Create a command-line project")
|
|
33
|
+
def add_cmd(_arg: ArgParser): # pylint: disable=unused-argument
|
|
34
|
+
pass
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@CommandExecutor(add_cmd, add_cmd_init)
|
|
38
|
+
def run_cmd(cmds: Command) -> int: # pylint: disable=unused-argument
|
|
39
|
+
return 0
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def main(argv: Optional[Sequence[str]] = None) -> int:
|
|
43
|
+
cmds = Command()
|
|
44
|
+
cmds.version = __version__
|
|
45
|
+
return cmds.run(root=add_cmd, argv=argv, epilog=f"For more, please visit {__urlhome__}.") # noqa:E501
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# coding:utf-8
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
from xkits_command.attribute import __author__
|
|
6
|
+
from xkits_command.attribute import __author_email__
|
|
7
|
+
from xkits_command.attribute import __project__
|
|
8
|
+
from xkits_command.attribute import __urlhome__
|
|
9
|
+
from xkits_command.attribute import __version__
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Project:
|
|
13
|
+
|
|
14
|
+
def __init__(self, name: str, license: str, allow_update: bool = False): # noqa:E501 pylint: disable=redefined-builtin
|
|
15
|
+
# check illegal characters in project name
|
|
16
|
+
for char in [" "]:
|
|
17
|
+
if char in name:
|
|
18
|
+
raise ValueError(f"Illegal character '{char}' in '{name}'")
|
|
19
|
+
self.__name: str = name
|
|
20
|
+
self.__module: str = self.get_module_name(name)
|
|
21
|
+
self.__license: str = license
|
|
22
|
+
self.__allow_update: bool = allow_update
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def name(self) -> str:
|
|
26
|
+
return self.__name
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def module(self) -> str:
|
|
30
|
+
return self.__module
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def license(self) -> str:
|
|
34
|
+
return self.__license
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
def allow_update(self) -> bool:
|
|
38
|
+
return self.__allow_update
|
|
39
|
+
|
|
40
|
+
@classmethod
|
|
41
|
+
def get_module_name(cls, project_name: str) -> str:
|
|
42
|
+
return project_name.replace("-", "_")
|
|
43
|
+
|
|
44
|
+
def write(self, path: str, content: str) -> bool:
|
|
45
|
+
if not os.path.exists(path) or self.allow_update:
|
|
46
|
+
with open(path, "w", encoding="utf-8") as whdl:
|
|
47
|
+
if len(content) > 0 and content[-1] != "\n":
|
|
48
|
+
content += "\n"
|
|
49
|
+
whdl.write(content)
|
|
50
|
+
return True
|
|
51
|
+
|
|
52
|
+
def init_requirements(self):
|
|
53
|
+
self.write("requirements.txt", f'''{__project__}>={__version__}''') # noqa:E501
|
|
54
|
+
|
|
55
|
+
def init_coveragerc(self):
|
|
56
|
+
self.write(".coveragerc", f'''[run]
|
|
57
|
+
omit =
|
|
58
|
+
{self.module}/unittest/*
|
|
59
|
+
{self.module}/attribute.py
|
|
60
|
+
|
|
61
|
+
[report]
|
|
62
|
+
exclude_lines =
|
|
63
|
+
pragma: no cover
|
|
64
|
+
raise NotImplementedError
|
|
65
|
+
if __name__ == .__main__.:
|
|
66
|
+
def __repr__
|
|
67
|
+
''')
|
|
68
|
+
|
|
69
|
+
def init_pylintrc(self):
|
|
70
|
+
self.write(".pylintrc", '''[MASTER]
|
|
71
|
+
disable=
|
|
72
|
+
C0103, # invalid-name
|
|
73
|
+
C0114, # missing-module-docstring
|
|
74
|
+
C0115, # missing-class-docstring
|
|
75
|
+
C0116, # missing-function-docstring
|
|
76
|
+
C0301, # line-too-long
|
|
77
|
+
''')
|
|
78
|
+
|
|
79
|
+
def init_makefile(self):
|
|
80
|
+
self.write("Makefile", f'''MAKEFLAGS += --always-make
|
|
81
|
+
|
|
82
|
+
VERSION := $(shell python3 setup.py --version)
|
|
83
|
+
|
|
84
|
+
all: build reinstall test
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
release: all
|
|
88
|
+
git tag -a v${{VERSION}} -m "release v${{VERSION}}"
|
|
89
|
+
git push origin --tags
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
clean-cover:
|
|
93
|
+
rm -rf cover .coverage coverage.xml htmlcov
|
|
94
|
+
clean-tox:
|
|
95
|
+
rm -rf .stestr .tox
|
|
96
|
+
clean: build-clean test-clean clean-cover clean-tox
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
upload:
|
|
100
|
+
xpip-upload --config-file .pypirc dist/*
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
build-clean:
|
|
104
|
+
xpip-build --debug setup --clean
|
|
105
|
+
build-requirements:
|
|
106
|
+
pip3 install -r requirements.txt
|
|
107
|
+
build: build-clean build-requirements
|
|
108
|
+
xpip-build --debug setup --all
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
install:
|
|
112
|
+
pip3 install --force-reinstall --no-deps dist/*.whl
|
|
113
|
+
uninstall:
|
|
114
|
+
pip3 uninstall -y {self.name}
|
|
115
|
+
reinstall: uninstall install
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
test-prepare:
|
|
119
|
+
pip3 install --upgrade mock pylint flake8 pytest pytest-cov
|
|
120
|
+
pylint:
|
|
121
|
+
pylint $(shell git ls-files {self.module}/*.py)
|
|
122
|
+
flake8:
|
|
123
|
+
flake8 {self.module} --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
124
|
+
flake8 {self.module} --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
|
125
|
+
pytest:
|
|
126
|
+
pytest --cov={self.module} --cov-report=term-missing --cov-report=xml --cov-report=html --cov-config=.coveragerc --cov-fail-under=100
|
|
127
|
+
pytest-clean:
|
|
128
|
+
rm -rf .pytest_cache
|
|
129
|
+
test: test-prepare pylint flake8 pytest
|
|
130
|
+
test-clean: pytest-clean
|
|
131
|
+
''') # noqa:W191,E101,E501
|
|
132
|
+
|
|
133
|
+
def init_project(self):
|
|
134
|
+
command_module = self.get_module_name(__project__)
|
|
135
|
+
os.makedirs(self.module, exist_ok=True)
|
|
136
|
+
os.makedirs(os.path.join(self.module, "unittest"), exist_ok=True)
|
|
137
|
+
self.write(os.path.join(self.module, "__init__.py"), "")
|
|
138
|
+
self.write(os.path.join(self.module, "unittest", "__init__.py"), "")
|
|
139
|
+
self.write(os.path.join(self.module, "attribute.py"),
|
|
140
|
+
f'''# coding:utf-8
|
|
141
|
+
|
|
142
|
+
__project__ = "{self.name}"
|
|
143
|
+
__version__ = "0.1.alpha.1"
|
|
144
|
+
__urlhome__ = "{__urlhome__}"
|
|
145
|
+
__description__ = "Automatically created by {__project__}."
|
|
146
|
+
|
|
147
|
+
# author
|
|
148
|
+
__author__ = "{__author__}"
|
|
149
|
+
__author_email__ = "{__author_email__}"
|
|
150
|
+
''')
|
|
151
|
+
self.write(os.path.join(self.module, "command.py"),
|
|
152
|
+
f'''# coding:utf-8
|
|
153
|
+
|
|
154
|
+
from typing import Optional
|
|
155
|
+
from typing import Sequence
|
|
156
|
+
|
|
157
|
+
from {command_module} import ArgParser
|
|
158
|
+
from {command_module} import Command
|
|
159
|
+
from {command_module} import CommandArgument
|
|
160
|
+
from {command_module} import CommandExecutor
|
|
161
|
+
|
|
162
|
+
from {self.module}.attribute import __description__
|
|
163
|
+
from {self.module}.attribute import __project__
|
|
164
|
+
from {self.module}.attribute import __urlhome__
|
|
165
|
+
from {self.module}.attribute import __version__
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
@CommandArgument(__project__, description=__description__)
|
|
169
|
+
def add_cmd(_arg: ArgParser): # pylint: disable=unused-argument
|
|
170
|
+
pass
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
@CommandExecutor(add_cmd)
|
|
174
|
+
def run_cmd(cmds: Command) -> int: # pylint: disable=unused-argument
|
|
175
|
+
return 0
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def main(argv: Optional[Sequence[str]] = None) -> int:
|
|
179
|
+
cmds = Command()
|
|
180
|
+
cmds.version = __version__
|
|
181
|
+
return cmds.run(root=add_cmd, argv=argv, epilog=f"For more, please visit {{__urlhome__}}.") # noqa:E501
|
|
182
|
+
''')
|
|
183
|
+
|
|
184
|
+
def init_readme(self):
|
|
185
|
+
self.write("README.md", f'''# {self.name}
|
|
186
|
+
|
|
187
|
+
> Automatically created by {__project__}.''')
|
|
188
|
+
|
|
189
|
+
def init_setup(self):
|
|
190
|
+
# create setup.cfg
|
|
191
|
+
self.write("setup.cfg", f'''[metadata]
|
|
192
|
+
keywords = command-line, argparse, argcomplete
|
|
193
|
+
long_description = file: README.md
|
|
194
|
+
long_description_content_type = text/markdown
|
|
195
|
+
license = {self.license}
|
|
196
|
+
license_files = LICENSE
|
|
197
|
+
platforms = any
|
|
198
|
+
classifiers =
|
|
199
|
+
Programming Language :: Python
|
|
200
|
+
Programming Language :: Python :: 3
|
|
201
|
+
|
|
202
|
+
[options]
|
|
203
|
+
zip_safe = True
|
|
204
|
+
include_package_data = True
|
|
205
|
+
python_requires = >=3.8
|
|
206
|
+
|
|
207
|
+
[options.entry_points]
|
|
208
|
+
console_scripts =
|
|
209
|
+
{self.name} = {self.module}.command:main
|
|
210
|
+
''')
|
|
211
|
+
|
|
212
|
+
# create setup.py
|
|
213
|
+
self.write("setup.py", f'''# coding=utf-8
|
|
214
|
+
|
|
215
|
+
from urllib.parse import urljoin
|
|
216
|
+
|
|
217
|
+
from setuptools import find_packages
|
|
218
|
+
from setuptools import setup
|
|
219
|
+
from setuptools.command.install import install
|
|
220
|
+
|
|
221
|
+
from {self.module}.attribute import __author__
|
|
222
|
+
from {self.module}.attribute import __author_email__
|
|
223
|
+
from {self.module}.attribute import __description__
|
|
224
|
+
from {self.module}.attribute import __project__
|
|
225
|
+
from {self.module}.attribute import __urlhome__
|
|
226
|
+
from {self.module}.attribute import __version__
|
|
227
|
+
|
|
228
|
+
__urlcode__ = __urlhome__
|
|
229
|
+
__urldocs__ = __urlhome__
|
|
230
|
+
__urlbugs__ = urljoin(__urlhome__, "issues")
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def all_requirements():
|
|
234
|
+
def read_requirements(path: str):
|
|
235
|
+
with open(path, "r", encoding="utf-8") as rhdl:
|
|
236
|
+
return rhdl.read().splitlines()
|
|
237
|
+
|
|
238
|
+
requirements = read_requirements("requirements.txt")
|
|
239
|
+
return requirements
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
class CustomInstallCommand(install):
|
|
243
|
+
"""Customized setuptools install command"""
|
|
244
|
+
|
|
245
|
+
def run(self):
|
|
246
|
+
install.run(self) # Run the standard installation
|
|
247
|
+
# Execute your custom code after installation
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
setup(
|
|
251
|
+
name=__project__,
|
|
252
|
+
version=__version__,
|
|
253
|
+
description=__description__,
|
|
254
|
+
url=__urlhome__,
|
|
255
|
+
author=__author__,
|
|
256
|
+
author_email=__author_email__,
|
|
257
|
+
project_urls={{"Source Code": __urlcode__,
|
|
258
|
+
"Bug Tracker": __urlbugs__,
|
|
259
|
+
"Documentation": __urldocs__}},
|
|
260
|
+
packages=find_packages(include=["{self.module}*"], exclude=["{self.module}.unittest"]), # noqa:E501
|
|
261
|
+
install_requires=all_requirements(),
|
|
262
|
+
cmdclass={{
|
|
263
|
+
"install": CustomInstallCommand,
|
|
264
|
+
}}
|
|
265
|
+
)
|
|
266
|
+
''') # noqa:E501
|
|
267
|
+
|
|
268
|
+
@classmethod
|
|
269
|
+
def create(cls, name: str, license: str, allow_update: bool = False) -> int: # noqa:E501 pylint: disable=redefined-builtin
|
|
270
|
+
instance = cls(name=name, license=license, allow_update=allow_update)
|
|
271
|
+
instance.init_requirements()
|
|
272
|
+
instance.init_coveragerc()
|
|
273
|
+
instance.init_pylintrc()
|
|
274
|
+
instance.init_makefile()
|
|
275
|
+
instance.init_project()
|
|
276
|
+
instance.init_readme()
|
|
277
|
+
instance.init_setup()
|
|
278
|
+
return 0
|
|
@@ -416,7 +416,7 @@ class Command(Log):
|
|
|
416
416
|
def __add_optional_version(self, _arg: ArgParser):
|
|
417
417
|
version = self.version
|
|
418
418
|
if not isinstance(version, str):
|
|
419
|
-
return
|
|
419
|
+
return # pragma: no cover
|
|
420
420
|
|
|
421
421
|
options = _arg.filter_optional_name("-v", "--version")
|
|
422
422
|
if len(options) > 0:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: xkits-command
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: Command line module
|
|
5
5
|
Home-page: https://github.com/bondbox/xcommand/
|
|
6
6
|
Author: Mingzhe Zou
|
|
@@ -21,4 +21,4 @@ Requires-Dist: xkits-logger>=0.2
|
|
|
21
21
|
|
|
22
22
|
# xcommand
|
|
23
23
|
|
|
24
|
-
Command line module
|
|
24
|
+
> Command line module
|
|
@@ -2,6 +2,9 @@ LICENSE
|
|
|
2
2
|
README.md
|
|
3
3
|
setup.cfg
|
|
4
4
|
setup.py
|
|
5
|
+
xargproject/__init__.py
|
|
6
|
+
xargproject/command.py
|
|
7
|
+
xargproject/project.py
|
|
5
8
|
xkits_command/__init__.py
|
|
6
9
|
xkits_command/actuator.py
|
|
7
10
|
xkits_command/attribute.py
|
|
@@ -9,6 +12,7 @@ xkits_command/parser.py
|
|
|
9
12
|
xkits_command.egg-info/PKG-INFO
|
|
10
13
|
xkits_command.egg-info/SOURCES.txt
|
|
11
14
|
xkits_command.egg-info/dependency_links.txt
|
|
15
|
+
xkits_command.egg-info/entry_points.txt
|
|
12
16
|
xkits_command.egg-info/requires.txt
|
|
13
17
|
xkits_command.egg-info/top_level.txt
|
|
14
18
|
xkits_command.egg-info/zip-safe
|
xkits_command-0.3/README.md
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|