dronefly-cli 0.2.6__tar.gz → 0.3.0__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.
- dronefly_cli-0.3.0/.gitignore +115 -0
- dronefly_cli-0.3.0/.pre-commit-config.yaml +24 -0
- {dronefly_cli-0.2.6 → dronefly_cli-0.3.0}/PKG-INFO +10 -11
- dronefly_cli-0.3.0/dronefly_cli/__init__.py +0 -0
- {dronefly_cli-0.2.6 → dronefly_cli-0.3.0}/dronefly_cli/main.py +63 -17
- dronefly_cli-0.3.0/pyproject.toml +64 -0
- dronefly_cli-0.3.0/uv.lock +1000 -0
- dronefly_cli-0.2.6/pyproject.toml +0 -33
- {dronefly_cli-0.2.6 → dronefly_cli-0.3.0}/LICENSE +0 -0
- {dronefly_cli-0.2.6 → dronefly_cli-0.3.0}/README.md +0 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
*.egg-info/
|
|
24
|
+
.installed.cfg
|
|
25
|
+
*.egg
|
|
26
|
+
MANIFEST
|
|
27
|
+
|
|
28
|
+
# PyInstaller
|
|
29
|
+
# Usually these files are written by a python script from a template
|
|
30
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
31
|
+
*.manifest
|
|
32
|
+
*.spec
|
|
33
|
+
|
|
34
|
+
# Installer logs
|
|
35
|
+
pip-log.txt
|
|
36
|
+
pip-delete-this-directory.txt
|
|
37
|
+
|
|
38
|
+
# Unit test / coverage reports
|
|
39
|
+
htmlcov/
|
|
40
|
+
.tox/
|
|
41
|
+
.coverage
|
|
42
|
+
.coverage.*
|
|
43
|
+
.cache
|
|
44
|
+
nosetests.xml
|
|
45
|
+
coverage.xml
|
|
46
|
+
*.cover
|
|
47
|
+
.hypothesis/
|
|
48
|
+
.pytest_cache/
|
|
49
|
+
|
|
50
|
+
# Translations
|
|
51
|
+
*.mo
|
|
52
|
+
*.pot
|
|
53
|
+
|
|
54
|
+
# Django stuff:
|
|
55
|
+
*.log
|
|
56
|
+
local_settings.py
|
|
57
|
+
db.sqlite3
|
|
58
|
+
|
|
59
|
+
# Flask stuff:
|
|
60
|
+
instance/
|
|
61
|
+
.webassets-cache
|
|
62
|
+
|
|
63
|
+
# Scrapy stuff:
|
|
64
|
+
.scrapy
|
|
65
|
+
|
|
66
|
+
# Sphinx documentation
|
|
67
|
+
docs/_build/
|
|
68
|
+
|
|
69
|
+
# PyBuilder
|
|
70
|
+
target/
|
|
71
|
+
|
|
72
|
+
# Jupyter Notebook
|
|
73
|
+
.ipynb_checkpoints
|
|
74
|
+
|
|
75
|
+
# pyenv
|
|
76
|
+
.python-version
|
|
77
|
+
|
|
78
|
+
# celery beat schedule file
|
|
79
|
+
celerybeat-schedule
|
|
80
|
+
|
|
81
|
+
# SageMath parsed files
|
|
82
|
+
*.sage.py
|
|
83
|
+
|
|
84
|
+
# Environments
|
|
85
|
+
.env
|
|
86
|
+
.venv
|
|
87
|
+
env/
|
|
88
|
+
venv/
|
|
89
|
+
ENV/
|
|
90
|
+
env.bak/
|
|
91
|
+
venv.bak/
|
|
92
|
+
|
|
93
|
+
# Spyder project settings
|
|
94
|
+
.spyderproject
|
|
95
|
+
.spyproject
|
|
96
|
+
|
|
97
|
+
# Rope project settings
|
|
98
|
+
.ropeproject
|
|
99
|
+
|
|
100
|
+
# mkdocs documentation
|
|
101
|
+
/site
|
|
102
|
+
|
|
103
|
+
# mypy
|
|
104
|
+
.mypy_cache/
|
|
105
|
+
|
|
106
|
+
# api keys
|
|
107
|
+
*.key
|
|
108
|
+
|
|
109
|
+
qgriff.ini
|
|
110
|
+
|
|
111
|
+
# Red Bot V3 stuff
|
|
112
|
+
red_setup_logs
|
|
113
|
+
|
|
114
|
+
# Visual Studio Code stuff
|
|
115
|
+
.vscode/
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
default_language_version:
|
|
2
|
+
python: python3.11
|
|
3
|
+
repos:
|
|
4
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
5
|
+
rev: v6.0.0
|
|
6
|
+
hooks:
|
|
7
|
+
- id: check-merge-conflict
|
|
8
|
+
- id: debug-statements
|
|
9
|
+
- repo: https://github.com/PyCQA/flake8
|
|
10
|
+
rev: 7.3.0
|
|
11
|
+
hooks:
|
|
12
|
+
- id: flake8
|
|
13
|
+
additional_dependencies:
|
|
14
|
+
- flake8-pyproject>=1.2.4,<2
|
|
15
|
+
- repo: https://github.com/psf/black
|
|
16
|
+
rev: 26.5.1
|
|
17
|
+
hooks:
|
|
18
|
+
- id: black
|
|
19
|
+
- repo: https://github.com/PyCQA/bandit
|
|
20
|
+
rev: 1.9.4
|
|
21
|
+
hooks:
|
|
22
|
+
- id: bandit
|
|
23
|
+
args: ["-c", "pyproject.toml"]
|
|
24
|
+
additional_dependencies: [ "bandit[toml]" ]
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: dronefly-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Dronefly command-line interface
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Requires-Python: >=3.11,<3.13
|
|
9
|
-
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
|
|
5
|
+
Author-email: Ben Armstrong <synrg@debian.org>
|
|
6
|
+
License-Expression: AGPL-3.0-or-later
|
|
7
|
+
License-File: LICENSE
|
|
10
8
|
Classifier: Programming Language :: Python :: 3
|
|
11
9
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
-
|
|
13
|
-
Requires-
|
|
14
|
-
Requires-Dist:
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Requires-Python: <3.13,>=3.11
|
|
12
|
+
Requires-Dist: dronefly-core>=0.5.2
|
|
13
|
+
Requires-Dist: pyreadline3<4,>=3.4.1
|
|
14
|
+
Requires-Dist: rich<14,>=13.2
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
|
|
17
17
|
# Dronefly command-line client
|
|
@@ -67,4 +67,3 @@ bot's core components.
|
|
|
67
67
|
Dronefly Discord bot brings [iNaturalist](https://www.inaturalist.org) taxa,
|
|
68
68
|
observations, and other data from the site into conversations on the
|
|
69
69
|
[Discord](https://discord.com) chat platform.
|
|
70
|
-
|
|
File without changes
|
|
@@ -3,21 +3,60 @@ import asyncio
|
|
|
3
3
|
import os
|
|
4
4
|
import sys
|
|
5
5
|
import readline
|
|
6
|
+
from inspect import getmembers, isroutine
|
|
6
7
|
|
|
7
|
-
from dronefly.core import
|
|
8
|
-
from dronefly.core.models import
|
|
9
|
-
from dronefly.core.commands import ArgumentError, CommandError
|
|
8
|
+
from dronefly.core import CLICommands, Format
|
|
9
|
+
from dronefly.core.models import Context, load_config, User
|
|
10
|
+
from dronefly.core.commands import ArgumentError, CommandError
|
|
10
11
|
from dronefly.core.constants import INAT_USER_DEFAULT_PARAMS
|
|
11
12
|
from rich.console import Console
|
|
13
|
+
from rich.markdown import Markdown
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
console = Console()
|
|
15
|
-
commands = Commands(format=Format.rich)
|
|
16
17
|
histfile = os.path.expanduser("~/.dronefly_history")
|
|
17
18
|
histfile_size = 1000
|
|
18
19
|
|
|
19
20
|
|
|
20
|
-
async def
|
|
21
|
+
async def help(ctx, *args):
|
|
22
|
+
"""Show help
|
|
23
|
+
Usage:
|
|
24
|
+
help Show help index
|
|
25
|
+
help <command> Show help for command""" # noqa: E501
|
|
26
|
+
|
|
27
|
+
def format_help_index_command(command, command_width):
|
|
28
|
+
command_help = f"{command[0].replace('_',' ').ljust(command_width)}"
|
|
29
|
+
if command[1].__doc__:
|
|
30
|
+
command_help += " " + command[1].__doc__.splitlines()[0]
|
|
31
|
+
return command_help
|
|
32
|
+
|
|
33
|
+
if len(args) == 0:
|
|
34
|
+
commands = [
|
|
35
|
+
*(
|
|
36
|
+
member
|
|
37
|
+
for member in getmembers(CLICommands, predicate=isroutine)
|
|
38
|
+
if member[0][0] != "_"
|
|
39
|
+
),
|
|
40
|
+
("help", help),
|
|
41
|
+
]
|
|
42
|
+
commands.sort(key=lambda x: x[0])
|
|
43
|
+
longest = max(len(member[0]) for member in commands)
|
|
44
|
+
response = "\n".join(
|
|
45
|
+
format_help_index_command(command, longest) for command in commands
|
|
46
|
+
)
|
|
47
|
+
return response
|
|
48
|
+
command_name = "_".join(args)
|
|
49
|
+
if command_name[0] != "_":
|
|
50
|
+
if command_name == "help":
|
|
51
|
+
command = help
|
|
52
|
+
else:
|
|
53
|
+
command = getattr(CLICommands, command_name, None)
|
|
54
|
+
if callable(command):
|
|
55
|
+
return f"Command: {command_name.replace('_', ' ')}\nDescription: {command.__doc__}"
|
|
56
|
+
return f"No help for: {' '.join(args)}"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
async def do_command(commands, command_str: str, ctx: Context, *args):
|
|
21
60
|
try:
|
|
22
61
|
command = None
|
|
23
62
|
_args = [*args]
|
|
@@ -26,12 +65,14 @@ async def do_command(command_str: str, ctx: Context, *args):
|
|
|
26
65
|
command = getattr(commands, subcommand, None)
|
|
27
66
|
if command:
|
|
28
67
|
_args.pop(0)
|
|
68
|
+
if command_str == "help":
|
|
69
|
+
command = help
|
|
29
70
|
if not command:
|
|
30
71
|
command = getattr(commands, command_str, None)
|
|
31
72
|
if not callable(command):
|
|
32
73
|
raise CommandError(f"No such command: {command_str}")
|
|
33
74
|
# TODO: Use command signatures to provide argument validation and conversion.
|
|
34
|
-
if (command_str not in ["life", "next", "prev", "page"]) and not _args:
|
|
75
|
+
if (command_str not in ["life", "next", "prev", "page", "help"]) and not _args:
|
|
35
76
|
raise ArgumentError("No arguments")
|
|
36
77
|
if command_str in ["next", "prev"] and _args:
|
|
37
78
|
raise ArgumentError("No argument expected")
|
|
@@ -46,14 +87,17 @@ async def do_command(command_str: str, ctx: Context, *args):
|
|
|
46
87
|
console.print(*response)
|
|
47
88
|
else:
|
|
48
89
|
console.print(response)
|
|
49
|
-
except (ArgumentError, CommandError) as err:
|
|
50
|
-
|
|
90
|
+
except (ArgumentError, CommandError, LookupError) as err:
|
|
91
|
+
if commands.format == Format.rich:
|
|
92
|
+
console.print(Markdown(str(err)))
|
|
93
|
+
else:
|
|
94
|
+
console.print(err)
|
|
51
95
|
|
|
52
96
|
|
|
53
|
-
def get_context():
|
|
97
|
+
async def get_context():
|
|
54
98
|
default_user_id = 1
|
|
55
|
-
config =
|
|
56
|
-
user_config = config.user(default_user_id)
|
|
99
|
+
config = load_config()
|
|
100
|
+
user_config = await config.user(default_user_id)
|
|
57
101
|
user_params = {"id": default_user_id}
|
|
58
102
|
for param in ("inat_user_id", *INAT_USER_DEFAULT_PARAMS):
|
|
59
103
|
param_value = None
|
|
@@ -66,7 +110,7 @@ def get_context():
|
|
|
66
110
|
if param_value:
|
|
67
111
|
user_params[param] = param_value
|
|
68
112
|
user = User(**user_params)
|
|
69
|
-
ctx = Context(author=user)
|
|
113
|
+
ctx = Context(author=user, config=config)
|
|
70
114
|
return ctx
|
|
71
115
|
|
|
72
116
|
|
|
@@ -80,7 +124,7 @@ def write_history(histfile, histfile_size):
|
|
|
80
124
|
readline.write_history_file(histfile)
|
|
81
125
|
|
|
82
126
|
|
|
83
|
-
async def start_command_loop(ctx, histfile, histfile_size):
|
|
127
|
+
async def start_command_loop(commands, ctx, histfile, histfile_size):
|
|
84
128
|
try:
|
|
85
129
|
read_history(histfile)
|
|
86
130
|
|
|
@@ -97,23 +141,25 @@ async def start_command_loop(ctx, histfile, histfile_size):
|
|
|
97
141
|
args = _line.split(" ")
|
|
98
142
|
command = args[0]
|
|
99
143
|
args.remove(command)
|
|
100
|
-
await do_command(command, ctx, *args)
|
|
144
|
+
await do_command(commands, command, ctx, *args)
|
|
101
145
|
except (KeyboardInterrupt, EOFError):
|
|
102
146
|
write_history(histfile, histfile_size)
|
|
103
147
|
console.print()
|
|
104
148
|
|
|
105
149
|
|
|
106
150
|
async def start():
|
|
107
|
-
ctx = get_context()
|
|
151
|
+
ctx = await get_context()
|
|
108
152
|
|
|
153
|
+
loop = asyncio.get_running_loop()
|
|
154
|
+
commands = CLICommands(loop=loop, format=Format.rich)
|
|
109
155
|
if len(sys.argv) == 1:
|
|
110
156
|
ctx.per_page = 20
|
|
111
|
-
await start_command_loop(ctx, histfile, histfile_size)
|
|
157
|
+
await start_command_loop(commands, ctx, histfile, histfile_size)
|
|
112
158
|
else:
|
|
113
159
|
ctx.per_page = 0
|
|
114
160
|
command = sys.argv[1]
|
|
115
161
|
args = sys.argv[2:]
|
|
116
|
-
await do_command(command, ctx, *args)
|
|
162
|
+
await do_command(commands, command, ctx, *args)
|
|
117
163
|
|
|
118
164
|
|
|
119
165
|
def main():
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "dronefly-cli"
|
|
3
|
+
version = "0.3.0"
|
|
4
|
+
description = "Dronefly command-line interface"
|
|
5
|
+
authors = [{ name = "Ben Armstrong", email = "synrg@debian.org" }]
|
|
6
|
+
requires-python = ">=3.11,<3.13"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
license = "AGPL-3.0-or-later"
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Programming Language :: Python :: 3",
|
|
11
|
+
"Programming Language :: Python :: 3.11",
|
|
12
|
+
"Programming Language :: Python :: 3.12",
|
|
13
|
+
]
|
|
14
|
+
dependencies = [
|
|
15
|
+
"pyreadline3>=3.4.1,<4",
|
|
16
|
+
"dronefly-core>=0.5.2",
|
|
17
|
+
"rich>=13.2,<14",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
dronefly = "dronefly_cli.main:main"
|
|
22
|
+
|
|
23
|
+
[tool.flake8]
|
|
24
|
+
max-line-length = 100
|
|
25
|
+
|
|
26
|
+
[dependency-groups]
|
|
27
|
+
dev = [
|
|
28
|
+
"black>=24.3.0,<25",
|
|
29
|
+
"pytest>=7.2.1,<8",
|
|
30
|
+
"pytest-mock>=3.10.0,<4",
|
|
31
|
+
"pylint>=2.10.2,<3",
|
|
32
|
+
"pytest-asyncio>=0.20.3,<0.21",
|
|
33
|
+
"pre-commit>=4.6.1",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[tool.black]
|
|
37
|
+
target-version = ['py311']
|
|
38
|
+
|
|
39
|
+
[tool.bandit]
|
|
40
|
+
exclude_dirs = ["tests"]
|
|
41
|
+
|
|
42
|
+
[build-system]
|
|
43
|
+
requires = ["hatchling"]
|
|
44
|
+
build-backend = "hatchling.build"
|
|
45
|
+
|
|
46
|
+
[tool.hatch.metadata]
|
|
47
|
+
allow-direct-references = true
|
|
48
|
+
|
|
49
|
+
[tool.hatch.build.targets.wheel]
|
|
50
|
+
packages = ["dronefly_cli"]
|
|
51
|
+
|
|
52
|
+
[tool.uv.sources]
|
|
53
|
+
# If you are using local editable installs for dronefly-core, ensure those are set here
|
|
54
|
+
# dronefly-core = { path = "../dronefly-core" }
|
|
55
|
+
|
|
56
|
+
[tool.setuptools]
|
|
57
|
+
packages = ["dronefly_cli"]
|
|
58
|
+
|
|
59
|
+
[tool.setuptools.package-dir]
|
|
60
|
+
"" = "."
|
|
61
|
+
|
|
62
|
+
[uv.tool.build-backend]
|
|
63
|
+
module-name = "dronefly_cli"
|
|
64
|
+
module-root = ""
|