hcs-core 0.1.308__py3-none-any.whl → 0.1.310__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.
- hcs_core/__init__.py +1 -1
- hcs_core/ctxp/cli_options.py +19 -3
- hcs_core/ctxp/cli_processor.py +10 -8
- hcs_core/ctxp/util.py +48 -1
- hcs_core/sglib/cli_options.py +2 -0
- {hcs_core-0.1.308.dist-info → hcs_core-0.1.310.dist-info}/METADATA +2 -2
- {hcs_core-0.1.308.dist-info → hcs_core-0.1.310.dist-info}/RECORD +8 -8
- {hcs_core-0.1.308.dist-info → hcs_core-0.1.310.dist-info}/WHEEL +1 -1
hcs_core/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.1.
|
|
1
|
+
__version__ = "0.1.310"
|
hcs_core/ctxp/cli_options.py
CHANGED
|
@@ -13,6 +13,8 @@ See the License for the specific language governing permissions and
|
|
|
13
13
|
limitations under the License.
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
|
+
import os
|
|
17
|
+
|
|
16
18
|
import click
|
|
17
19
|
|
|
18
20
|
verbose = click.option(
|
|
@@ -27,7 +29,7 @@ verbose = click.option(
|
|
|
27
29
|
output = click.option(
|
|
28
30
|
"--output",
|
|
29
31
|
"-o",
|
|
30
|
-
type=click.Choice(["json", "json-compact", "yaml", "yml", "
|
|
32
|
+
type=click.Choice(["json", "json-compact", "yaml", "yml", "table", "t", "text"], case_sensitive=False),
|
|
31
33
|
default=None,
|
|
32
34
|
hidden=True,
|
|
33
35
|
help="Specify output format",
|
|
@@ -101,10 +103,24 @@ force = click.option("--force/--grace", type=bool, default=True, help="Specify d
|
|
|
101
103
|
|
|
102
104
|
confirm = click.option("--confirm/--prompt", "-y", type=bool, default=False, help="Confirm the operation without prompt.")
|
|
103
105
|
|
|
106
|
+
env = click.option(
|
|
107
|
+
"--env",
|
|
108
|
+
multiple=True,
|
|
109
|
+
type=str,
|
|
110
|
+
required=False,
|
|
111
|
+
help="Alternative explicit in-line environment variable override in KEY=VALUE format.",
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def apply_env(envs):
|
|
116
|
+
for kv in envs:
|
|
117
|
+
k, v = kv.split("=", 1)
|
|
118
|
+
os.environ[k.strip()] = v.strip()
|
|
119
|
+
|
|
104
120
|
|
|
105
|
-
def formatter(
|
|
121
|
+
def formatter(formatter=None, columns=None):
|
|
106
122
|
def decorator(f):
|
|
107
|
-
f.formatter =
|
|
123
|
+
f.formatter = formatter if formatter else columns
|
|
108
124
|
return f
|
|
109
125
|
|
|
110
126
|
return decorator
|
hcs_core/ctxp/cli_processor.py
CHANGED
|
@@ -24,7 +24,7 @@ from pathlib import Path
|
|
|
24
24
|
import click
|
|
25
25
|
from click.core import Group
|
|
26
26
|
|
|
27
|
-
from .util import avoid_trace_for_ctrl_c, print_error, print_output, validate_error_return
|
|
27
|
+
from .util import avoid_trace_for_ctrl_c, default_table_formatter, print_error, print_output, validate_error_return
|
|
28
28
|
|
|
29
29
|
_eager_loading = os.environ.get("_CTXP_EAGER_LOAD")
|
|
30
30
|
if _eager_loading:
|
|
@@ -192,15 +192,17 @@ def _default_io(cmd: click.Command):
|
|
|
192
192
|
|
|
193
193
|
telemetry_update(ctx.command_path, ctx.params)
|
|
194
194
|
|
|
195
|
-
if io_args["output"] == "table":
|
|
195
|
+
if io_args["output"] == "table" or io_args["output"] == "t":
|
|
196
196
|
|
|
197
197
|
def _format(data):
|
|
198
|
-
if
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
198
|
+
if hasattr(callback, "formatter"):
|
|
199
|
+
formatter = callback.__getattribute__("formatter")
|
|
200
|
+
else:
|
|
201
|
+
formatter = default_table_formatter
|
|
202
|
+
if isinstance(formatter, dict):
|
|
203
|
+
return default_table_formatter(data, formatter)
|
|
204
|
+
else:
|
|
205
|
+
return formatter(data)
|
|
204
206
|
|
|
205
207
|
io_args["format"] = _format
|
|
206
208
|
ret = callback(*args, **kwargs)
|
hcs_core/ctxp/util.py
CHANGED
|
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
|
|
|
13
13
|
limitations under the License.
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
|
+
import datetime
|
|
16
17
|
import json
|
|
17
18
|
import os
|
|
18
19
|
import re
|
|
@@ -26,6 +27,7 @@ import click
|
|
|
26
27
|
import httpx
|
|
27
28
|
import questionary
|
|
28
29
|
import yaml
|
|
30
|
+
import yumako
|
|
29
31
|
|
|
30
32
|
|
|
31
33
|
class CtxpException(Exception):
|
|
@@ -112,7 +114,7 @@ def print_output(data: Any, args: dict, file=sys.stdout):
|
|
|
112
114
|
text = data
|
|
113
115
|
else:
|
|
114
116
|
text = json.dumps(data, indent=4)
|
|
115
|
-
elif output == "table":
|
|
117
|
+
elif output == "table" or output == "t":
|
|
116
118
|
formatter = args["format"]
|
|
117
119
|
text = formatter(data)
|
|
118
120
|
else:
|
|
@@ -411,3 +413,48 @@ def colorize(data: dict, name: str, mapping: dict):
|
|
|
411
413
|
data[name] = click.style(s, fg=c)
|
|
412
414
|
else:
|
|
413
415
|
raise Exception(f"Unexpected mapping type: {type(mapping)} {mapping}")
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
def default_table_formatter(data: Any, mapping: dict = None):
|
|
419
|
+
if not isinstance(data, list):
|
|
420
|
+
return data
|
|
421
|
+
|
|
422
|
+
def _restrict_readable_length(data: dict, name: str, length: int):
|
|
423
|
+
text = data.get(name)
|
|
424
|
+
if not text:
|
|
425
|
+
return
|
|
426
|
+
if len(text) > length:
|
|
427
|
+
data[name] = text[: length - 3] + "..."
|
|
428
|
+
|
|
429
|
+
field_mapping = {}
|
|
430
|
+
for d in data:
|
|
431
|
+
if "id" in d:
|
|
432
|
+
field_mapping["id"] = "Id"
|
|
433
|
+
if "name" in d:
|
|
434
|
+
field_mapping["name"] = "Name"
|
|
435
|
+
if "location" in d:
|
|
436
|
+
field_mapping["location"] = "Location"
|
|
437
|
+
if "type" in d:
|
|
438
|
+
field_mapping["type"] = "Type"
|
|
439
|
+
if "status" in d:
|
|
440
|
+
field_mapping["status"] = "Status"
|
|
441
|
+
if "createdAt" in d:
|
|
442
|
+
d["_createdStale"] = yumako.time.stale(d["createdAt"], datetime.timezone.utc)
|
|
443
|
+
field_mapping["_createdStale"] = "Created At"
|
|
444
|
+
if "updatedAt" in d:
|
|
445
|
+
d["_updatedStale"] = yumako.time.stale(d["updatedAt"], datetime.timezone.utc)
|
|
446
|
+
field_mapping["_updatedStale"] = "Updated At"
|
|
447
|
+
|
|
448
|
+
colorize(
|
|
449
|
+
d,
|
|
450
|
+
"status",
|
|
451
|
+
{
|
|
452
|
+
"READY": "green",
|
|
453
|
+
"SUCCESS": "green",
|
|
454
|
+
"ERROR": "red",
|
|
455
|
+
},
|
|
456
|
+
)
|
|
457
|
+
_restrict_readable_length(d, "name", 60)
|
|
458
|
+
if mapping:
|
|
459
|
+
field_mapping.update(mapping)
|
|
460
|
+
return format_table(data, fields_mapping=field_mapping)
|
hcs_core/sglib/cli_options.py
CHANGED
|
@@ -18,7 +18,9 @@ import os
|
|
|
18
18
|
import click
|
|
19
19
|
|
|
20
20
|
from hcs_core.ctxp import CtxpException, recent
|
|
21
|
+
from hcs_core.ctxp.cli_options import apply_env as apply_env
|
|
21
22
|
from hcs_core.ctxp.cli_options import confirm as confirm
|
|
23
|
+
from hcs_core.ctxp.cli_options import env as env
|
|
22
24
|
from hcs_core.ctxp.cli_options import exclude_field as exclude_field
|
|
23
25
|
from hcs_core.ctxp.cli_options import field as field
|
|
24
26
|
from hcs_core.ctxp.cli_options import first as first
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hcs-core
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.310
|
|
4
4
|
Summary: Horizon Cloud Service CLI module.
|
|
5
5
|
Project-URL: Homepage, https://github.com/euc-eng/hcs-cli
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/euc-eng/hcs-cli/issues
|
|
@@ -36,7 +36,7 @@ Requires-Dist: schedule>=1.1.0
|
|
|
36
36
|
Requires-Dist: setuptools>=70.0.0
|
|
37
37
|
Requires-Dist: tabulate>=0.9.0
|
|
38
38
|
Requires-Dist: websocket-client>=1.2.3
|
|
39
|
-
Requires-Dist: yumako>=0.1.
|
|
39
|
+
Requires-Dist: yumako>=0.1.36
|
|
40
40
|
Provides-Extra: dev
|
|
41
41
|
Requires-Dist: bandit; extra == 'dev'
|
|
42
42
|
Requires-Dist: black; extra == 'dev'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
hcs_core/__init__.py,sha256=
|
|
1
|
+
hcs_core/__init__.py,sha256=qNe_N_xOYVLW7IcTJNa4ZbiRGoqGLfwqhzHzTvVvWq0,24
|
|
2
2
|
hcs_core/ctxp/__init__.py,sha256=bHVHhJP10Luz1a3Kk3zFx14dAO4SY6Q20Lrv8rNWWGc,1075
|
|
3
3
|
hcs_core/ctxp/_init.py,sha256=fMcRMPfJx-N0c-u0Zj2sFVKQL1-lWQd28gooAZETGUA,2933
|
|
4
|
-
hcs_core/ctxp/cli_options.py,sha256=
|
|
5
|
-
hcs_core/ctxp/cli_processor.py,sha256=
|
|
4
|
+
hcs_core/ctxp/cli_options.py,sha256=KFu9_cRB1OyXaZJFLDCb3PpuQ0_5-ou2cdaL_q0_Lns,3098
|
|
5
|
+
hcs_core/ctxp/cli_processor.py,sha256=thxNqGIztWTdhDWgzs5NopCSk8yDy1FzG-weqfmIUbE,7756
|
|
6
6
|
hcs_core/ctxp/cmd_util.py,sha256=_-VwQSmkfi52qWC3uHQI06mSiIPfsZroDruTDYHXiMA,3119
|
|
7
7
|
hcs_core/ctxp/config.py,sha256=vRdzPxi3Yrt04cnR6b5mJwEOtYBh21qvmlSSsgyGoI4,931
|
|
8
8
|
hcs_core/ctxp/context.py,sha256=LafhucyGRGYLmnXoZLZOKRWXUwJ1KzP-6vjDTTrC8j4,3451
|
|
@@ -22,7 +22,7 @@ hcs_core/ctxp/task_schd.py,sha256=mvZMeKDSSo2p7VidSoZY1XZj433TQn_YF9SGJEzl9lg,45
|
|
|
22
22
|
hcs_core/ctxp/telemetry.py,sha256=tSjI_8OE2Ix3n--YHAO9sPmzi8ETbFHEPxzS52-usmM,3476
|
|
23
23
|
hcs_core/ctxp/template_util.py,sha256=XslvIuRBlTVsUW0Y9M_D8gUPc1jWq6X2p4At2VAe1KU,731
|
|
24
24
|
hcs_core/ctxp/timeutil.py,sha256=RyRrIRdFHbIghdB8wbC8VdABvc7hki2v51b1x2JvHgo,445
|
|
25
|
-
hcs_core/ctxp/util.py,sha256=
|
|
25
|
+
hcs_core/ctxp/util.py,sha256=UTTtP-jjt3r5N-CTf0We64yLPWfFIl9dNSHkfsbFvLY,14225
|
|
26
26
|
hcs_core/ctxp/var_template.py,sha256=cTjj1UJ58ac6s5z4Oh5hSDQwKixq-rdbCF1D8akjAo0,3219
|
|
27
27
|
hcs_core/ctxp/built_in_cmds/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
28
|
hcs_core/ctxp/built_in_cmds/_ut.py,sha256=e50XBmPim2qRe0RYk_XAuRz1HWYyLJuMu-6dVxWR_fQ,3356
|
|
@@ -43,7 +43,7 @@ hcs_core/plan/provider/dev/dummy.py,sha256=zKEr9J4WHhlN5gFdmrFyEfCF0xlQlCJg0CC1d
|
|
|
43
43
|
hcs_core/plan/provider/dev/fibonacci.py,sha256=8WhDr5c9harNAlVPZomQJEqbWe0hUqbppO6ZkwEUcJ0,1104
|
|
44
44
|
hcs_core/sglib/__init__.py,sha256=oT0etW7vsEbHlXiGL5x23ZXyyFqeLi81RxQQ5lfKSV0,654
|
|
45
45
|
hcs_core/sglib/auth.py,sha256=r9zgLdnybuHsf3_j6nTP4SGoS2dD3keYZ-c25o2Mx64,6766
|
|
46
|
-
hcs_core/sglib/cli_options.py,sha256=
|
|
46
|
+
hcs_core/sglib/cli_options.py,sha256=GBJ59u9iWiCfJt-5F8qw_JGfMRfB-LcLeiKAQkmMh_c,2548
|
|
47
47
|
hcs_core/sglib/client_util.py,sha256=4YH-QoqkpF2DtXhemYx4vM19YBzUWk4iNL2BvYLTDmg,14617
|
|
48
48
|
hcs_core/sglib/csp.py,sha256=UcO68YtLOPDQWiTjPVIPwQ2Z-Mywc-154aoIkLdyzwE,10991
|
|
49
49
|
hcs_core/sglib/ez_client.py,sha256=dWQx-EMTrySz1EVzsSu4ZezORR3_iEOAcZigtbuvIQ8,8404
|
|
@@ -64,6 +64,6 @@ hcs_core/util/query_util.py,sha256=uYfcEF_00eUs_S5OK64zpH0cnb6dwy91_J1OY5ZrFVs,3
|
|
|
64
64
|
hcs_core/util/scheduler.py,sha256=bPpCmGUL1UctJMfLPAg-h4Hl2YZr96FiI78-G_Usn08,2958
|
|
65
65
|
hcs_core/util/ssl_util.py,sha256=MvU102fGwWWh9hhSmLnn1qQIWuD6TjZnN0iH0MXUtW0,1239
|
|
66
66
|
hcs_core/util/versions.py,sha256=6nyyZzi3P69WQfioPc2_YWZQcUc13mC1eKoK58b3WUQ,1709
|
|
67
|
-
hcs_core-0.1.
|
|
68
|
-
hcs_core-0.1.
|
|
69
|
-
hcs_core-0.1.
|
|
67
|
+
hcs_core-0.1.310.dist-info/METADATA,sha256=1tBWDUz8FAPMkCurFREuONeUiZ-udR5Jk8Mup3SH81g,1951
|
|
68
|
+
hcs_core-0.1.310.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
69
|
+
hcs_core-0.1.310.dist-info/RECORD,,
|