dronefly-cli 0.2.2__tar.gz → 0.2.4__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.2.2 → dronefly_cli-0.2.4}/PKG-INFO +3 -5
- {dronefly_cli-0.2.2 → dronefly_cli-0.2.4}/dronefly_cli/main.py +29 -12
- {dronefly_cli-0.2.2 → dronefly_cli-0.2.4}/pyproject.toml +4 -4
- {dronefly_cli-0.2.2 → dronefly_cli-0.2.4}/LICENSE +0 -0
- {dronefly_cli-0.2.2 → dronefly_cli-0.2.4}/README.md +0 -0
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dronefly-cli
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Dronefly command-line interface
|
|
5
5
|
License: AGPL-3.0-or-later
|
|
6
6
|
Author: Ben Armstrong
|
|
7
7
|
Author-email: synrg@debian.org
|
|
8
|
-
Requires-Python: >=3.
|
|
8
|
+
Requires-Python: >=3.11,<3.13
|
|
9
9
|
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
13
11
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
-
Requires-Dist: dronefly-core (==0.3.
|
|
12
|
+
Requires-Dist: dronefly-core (==0.3.9.dev1)
|
|
15
13
|
Requires-Dist: pyreadline3 (>=3.4.1,<4.0.0)
|
|
16
14
|
Requires-Dist: rich (>=13.2,<14.0)
|
|
17
15
|
Description-Content-Type: text/markdown
|
|
@@ -4,7 +4,7 @@ import sys
|
|
|
4
4
|
import readline
|
|
5
5
|
|
|
6
6
|
from dronefly.core import Commands, Format
|
|
7
|
-
from dronefly.core.models
|
|
7
|
+
from dronefly.core.models import Config, User
|
|
8
8
|
from dronefly.core.commands import ArgumentError, CommandError, Context
|
|
9
9
|
from dronefly.core.constants import INAT_USER_DEFAULT_PARAMS
|
|
10
10
|
from rich.console import Console
|
|
@@ -18,21 +18,29 @@ histfile_size = 1000
|
|
|
18
18
|
|
|
19
19
|
def do_command(command_str: str, ctx: Context, *args):
|
|
20
20
|
try:
|
|
21
|
-
command =
|
|
21
|
+
command = None
|
|
22
|
+
_args = [*args]
|
|
23
|
+
if len(_args) > 0:
|
|
24
|
+
subcommand = "_".join([command_str, _args[0]])
|
|
25
|
+
command = getattr(commands, subcommand, None)
|
|
26
|
+
if command:
|
|
27
|
+
_args.pop(0)
|
|
28
|
+
if not command:
|
|
29
|
+
command = getattr(commands, command_str, None)
|
|
22
30
|
if not callable(command):
|
|
23
31
|
raise CommandError(f"No such command: {command_str}")
|
|
24
32
|
# TODO: Use command signatures to provide argument validation and conversion.
|
|
25
|
-
if (command_str not in ["life", "next", "prev", "page"]) and not
|
|
33
|
+
if (command_str not in ["life", "next", "prev", "page"]) and not _args:
|
|
26
34
|
raise ArgumentError("No arguments")
|
|
27
|
-
if command_str in ["next", "prev"] and
|
|
35
|
+
if command_str in ["next", "prev"] and _args:
|
|
28
36
|
raise ArgumentError("No argument expected")
|
|
29
|
-
if command_str in ["page"] and len(
|
|
37
|
+
if command_str in ["page"] and len(_args) > 1:
|
|
30
38
|
raise ArgumentError("Too many arguments")
|
|
31
39
|
# Argument conversion, if necessary:
|
|
32
|
-
if command_str in ["page", "sel"] and len(
|
|
33
|
-
response = command(ctx, int(
|
|
40
|
+
if command_str in ["page", "sel"] and len(_args):
|
|
41
|
+
response = command(ctx, int(_args[0]))
|
|
34
42
|
else:
|
|
35
|
-
response = command(ctx, *
|
|
43
|
+
response = command(ctx, *_args)
|
|
36
44
|
if isinstance(response, list):
|
|
37
45
|
console.print(*response)
|
|
38
46
|
else:
|
|
@@ -42,11 +50,20 @@ def do_command(command_str: str, ctx: Context, *args):
|
|
|
42
50
|
|
|
43
51
|
|
|
44
52
|
def get_context():
|
|
45
|
-
|
|
53
|
+
default_user_id = 1
|
|
54
|
+
config = Config()
|
|
55
|
+
user_config = config.user(default_user_id)
|
|
56
|
+
user_params = {"id": default_user_id}
|
|
46
57
|
for param in ("inat_user_id", *INAT_USER_DEFAULT_PARAMS):
|
|
47
|
-
|
|
48
|
-
if
|
|
49
|
-
|
|
58
|
+
param_value = None
|
|
59
|
+
if user_config:
|
|
60
|
+
param_value = user_config.get(param)
|
|
61
|
+
if not param_value:
|
|
62
|
+
param_value = os.environ.get(param.upper())
|
|
63
|
+
if param_value and param_value.isnumeric():
|
|
64
|
+
param_value = int(param_value)
|
|
65
|
+
if param_value:
|
|
66
|
+
user_params[param] = param_value
|
|
50
67
|
user = User(**user_params)
|
|
51
68
|
ctx = Context(author=user)
|
|
52
69
|
return ctx
|
|
@@ -6,20 +6,20 @@ exclude_dirs = ["tests"]
|
|
|
6
6
|
|
|
7
7
|
[tool.poetry]
|
|
8
8
|
name = "dronefly-cli"
|
|
9
|
-
version = "0.2.
|
|
9
|
+
version = "0.2.4"
|
|
10
10
|
description = "Dronefly command-line interface"
|
|
11
11
|
authors = ["Ben Armstrong <synrg@debian.org>"]
|
|
12
12
|
license = "AGPL-3.0-or-later"
|
|
13
13
|
readme = "README.md"
|
|
14
14
|
|
|
15
15
|
[tool.poetry.dependencies]
|
|
16
|
-
python = ">=3.
|
|
16
|
+
python = ">=3.11,<3.13"
|
|
17
17
|
pyreadline3 = "^3.4.1"
|
|
18
|
-
dronefly-core = "0.3.
|
|
18
|
+
dronefly-core = "0.3.9.dev1"
|
|
19
19
|
rich = "^13.2"
|
|
20
20
|
|
|
21
21
|
[tool.poetry.dev-dependencies]
|
|
22
|
-
black = "^
|
|
22
|
+
black = "^24.3.0"
|
|
23
23
|
pytest = "^7.2.1"
|
|
24
24
|
pytest-mock = "^3.10.0"
|
|
25
25
|
pylint = "^2.10.2"
|
|
File without changes
|
|
File without changes
|