kaqing 2.0.43__tar.gz → 2.0.44__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.
- {kaqing-2.0.43 → kaqing-2.0.44}/PKG-INFO +1 -1
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/postgres/postgres.py +2 -15
- kaqing-2.0.44/adam/commands/postgres/postgres_completions.py +24 -0
- kaqing-2.0.44/adam/pg_table_completer.py +77 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/repl.py +2 -5
- kaqing-2.0.44/adam/version.py +5 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/kaqing.egg-info/PKG-INFO +1 -1
- {kaqing-2.0.43 → kaqing-2.0.44}/kaqing.egg-info/SOURCES.txt +2 -1
- {kaqing-2.0.43 → kaqing-2.0.44}/setup.py +1 -1
- kaqing-2.0.43/adam/repl_completer.py +0 -74
- kaqing-2.0.43/adam/version.py +0 -5
- {kaqing-2.0.43 → kaqing-2.0.44}/README +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/__init__.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/app_session.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/apps.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/batch.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/checks/__init__.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/checks/check.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/checks/check_context.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/checks/check_result.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/checks/check_utils.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/checks/compactionstats.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/checks/cpu.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/checks/disk.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/checks/gossip.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/checks/issue.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/checks/memory.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/checks/status.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/cli.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/cli_group.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/__init__.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/column.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/columns.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/compactions.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/cpu.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/dir_data.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/dir_snapshots.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/gossip.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/host_id.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/memory.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/node_address.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/node_load.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/node_owns.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/node_status.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/node_tokens.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/node_utils.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/pod_name.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/volume_cassandra.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/columns/volume_root.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/__init__.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/alter_tables.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/app.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/app_ping.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/bash.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/cd.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/check.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/cli_commands.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/command.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/command_helpers.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/commands_utils.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/cp.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/cql_utils.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/cqlsh.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/deploy/__init__.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/deploy/code_start.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/deploy/code_stop.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/deploy/code_utils.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/deploy/deploy.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/deploy/deploy_frontend.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/deploy/deploy_pg_agent.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/deploy/deploy_pod.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/deploy/deploy_utils.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/deploy/undeploy.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/deploy/undeploy_frontend.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/deploy/undeploy_pg_agent.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/deploy/undeploy_pod.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/describe/__init__.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/describe/describe.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/describe/describe_keyspace.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/describe/describe_keyspaces.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/describe/describe_table.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/describe/describe_tables.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/devices.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/exit.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/help.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/issues.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/login.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/logs.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/ls.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/medusa/__init__.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/medusa/medusa.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/medusa/medusa_backup.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/medusa/medusa_restore.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/medusa/medusa_show_backupjobs.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/medusa/medusa_show_restorejobs.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/nodetool.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/nodetool_commands.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/param_get.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/param_set.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/postgres/__init__.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/postgres/postgres_ls.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/postgres/postgres_preview.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/postgres/postgres_session.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/postgres/postgres_utils.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/preview_table.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/pwd.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/reaper/__init__.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/reaper/reaper.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/reaper/reaper_forward.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/reaper/reaper_forward_stop.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/reaper/reaper_restart.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/reaper/reaper_run_abort.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/reaper/reaper_runs.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/reaper/reaper_runs_abort.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/reaper/reaper_schedule_activate.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/reaper/reaper_schedule_start.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/reaper/reaper_schedule_stop.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/reaper/reaper_schedules.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/reaper/reaper_session.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/reaper/reaper_status.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/repair/__init__.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/repair/repair.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/repair/repair_log.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/repair/repair_run.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/repair/repair_scan.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/repair/repair_stop.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/report.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/restart.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/rollout.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/shell.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/show/__init__.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/show/show.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/show/show_adam.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/show/show_app_actions.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/show/show_app_id.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/show/show_app_queues.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/show/show_cassandra_status.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/show/show_cassandra_version.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/show/show_commands.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/show/show_login.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/show/show_params.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/show/show_processes.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/show/show_repairs.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/show/show_storage.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/commands/watch.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/config.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/embedded_apps.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/embedded_params.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/k8s_utils/__init__.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/k8s_utils/cassandra_clusters.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/k8s_utils/cassandra_nodes.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/k8s_utils/config_maps.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/k8s_utils/custom_resources.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/k8s_utils/deployment.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/k8s_utils/ingresses.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/k8s_utils/jobs.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/k8s_utils/kube_context.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/k8s_utils/pods.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/k8s_utils/secrets.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/k8s_utils/service_accounts.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/k8s_utils/services.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/k8s_utils/statefulsets.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/k8s_utils/volumes.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/log.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/pod_exec_result.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/repl_commands.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/repl_session.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/repl_state.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/sso/__init__.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/sso/authenticator.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/sso/authn_ad.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/sso/authn_okta.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/sso/cred_cache.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/sso/id_token.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/sso/idp.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/sso/idp_login.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/sso/idp_session.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/sso/sso_config.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/adam/utils.py +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/kaqing.egg-info/dependency_links.txt +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/kaqing.egg-info/entry_points.txt +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/kaqing.egg-info/top_level.txt +0 -0
- {kaqing-2.0.43 → kaqing-2.0.44}/setup.cfg +0 -0
@@ -1,7 +1,7 @@
|
|
1
|
-
import functools
|
2
1
|
import click
|
3
2
|
|
4
3
|
from adam.commands.command import Command
|
4
|
+
from adam.commands.postgres.postgres_completions import pg_completions
|
5
5
|
from adam.commands.postgres.postgres_utils import pg_table_names
|
6
6
|
from .postgres_ls import PostgresLs
|
7
7
|
from .postgres_preview import PostgresPreview
|
@@ -69,20 +69,7 @@ class Postgres(Command):
|
|
69
69
|
session = PostgresSession(state.namespace, state.pg_path)
|
70
70
|
if session.db:
|
71
71
|
if pg_table_names(state.namespace, state.pg_path):
|
72
|
-
|
73
|
-
leaf = {
|
74
|
-
'\h': None,
|
75
|
-
'\d': None,
|
76
|
-
'\dt': None,
|
77
|
-
'\du': None,
|
78
|
-
'delete': {'from': {ts: {'where': {'id': {'=': None}}}}},
|
79
|
-
'insert': {'into': {ts: {'values': None}}},
|
80
|
-
'select': {'*': {'from': {ts: {
|
81
|
-
'limit': {'1': None},
|
82
|
-
'where': {'id': {'=': None}}
|
83
|
-
}}}},
|
84
|
-
'update': {ts: {'set': None}},
|
85
|
-
}
|
72
|
+
leaf = pg_completions(state.namespace, state.pg_path)
|
86
73
|
elif state.pg_path:
|
87
74
|
leaf = {
|
88
75
|
'\h': None,
|
@@ -0,0 +1,24 @@
|
|
1
|
+
from adam.pg_table_completer import PgTableCompleter
|
2
|
+
|
3
|
+
def pg_completions(ns: str, pg_path: str):
|
4
|
+
table = PgTableCompleter(ns, pg_path)
|
5
|
+
return {
|
6
|
+
'\h': None,
|
7
|
+
'\d': None,
|
8
|
+
'\dt': None,
|
9
|
+
'\du': None,
|
10
|
+
# 'delete': {'from': {ts: {'where': {'id': {'=': None}}}}},
|
11
|
+
# 'insert': {'into': {ts: {'values': None}}},
|
12
|
+
# 'select': {'*': {'from': {ts: {
|
13
|
+
# 'limit': {'1': None},
|
14
|
+
# 'where': {'id': {'=': None}}
|
15
|
+
# }}}},
|
16
|
+
# 'update': {ts: {'set': None}},
|
17
|
+
'delete': {'from': table.nested({'where': {'id': {'=': None}}})},
|
18
|
+
'insert': {'into': table.nested({'values': None})},
|
19
|
+
'select': {'*': {'from': table.nested({
|
20
|
+
'limit': {'1': None},
|
21
|
+
'where': {'id': {'=': None}}
|
22
|
+
})}},
|
23
|
+
'update': table.nested({'set': None}),
|
24
|
+
}
|
@@ -0,0 +1,77 @@
|
|
1
|
+
from typing import Any, Dict, Iterable, Mapping, Optional, Set, Union
|
2
|
+
from prompt_toolkit.completion import CompleteEvent, Completer, Completion, NestedCompleter, WordCompleter
|
3
|
+
from prompt_toolkit.document import Document
|
4
|
+
|
5
|
+
from adam.commands.postgres.postgres_utils import pg_table_names
|
6
|
+
|
7
|
+
NestedDict = Mapping[str, Union[Any, Set[str], None, Completer]]
|
8
|
+
|
9
|
+
class PgTableCompleter(Completer):
|
10
|
+
def __init__(self, namespace: str, pg_path: str, nested_dict: NestedDict = None, ignore_case: bool = True):
|
11
|
+
self.namespace = namespace
|
12
|
+
self.pg_path = pg_path
|
13
|
+
self.ignore_case = ignore_case
|
14
|
+
if nested_dict:
|
15
|
+
self.append_nested_dict(nested_dict)
|
16
|
+
|
17
|
+
def __repr__(self) -> str:
|
18
|
+
return "PgTableCompleter(%r, pg_path=%r)" % (self.namespace, self.pg_path)
|
19
|
+
|
20
|
+
def nested(self, data: NestedDict):
|
21
|
+
return PgTableCompleter(self.namespace, self.pg_path).append_nested_dict(data)
|
22
|
+
|
23
|
+
def append_nested_dict(self, data: NestedDict) -> "PgTableCompleter":
|
24
|
+
options: Dict[str, Optional[Completer]] = {}
|
25
|
+
for key, value in data.items():
|
26
|
+
if isinstance(value, Completer):
|
27
|
+
options[key] = value
|
28
|
+
elif isinstance(value, dict):
|
29
|
+
options[key] = NestedCompleter.from_nested_dict(value)
|
30
|
+
elif isinstance(value, set):
|
31
|
+
options[key] = NestedCompleter.from_nested_dict({item: None for item in value})
|
32
|
+
else:
|
33
|
+
assert value is None
|
34
|
+
options[key] = None
|
35
|
+
|
36
|
+
self.options = options
|
37
|
+
|
38
|
+
return self
|
39
|
+
|
40
|
+
def get_completions(
|
41
|
+
self, document: Document, complete_event: CompleteEvent
|
42
|
+
) -> Iterable[Completion]:
|
43
|
+
text = document.text_before_cursor.lstrip()
|
44
|
+
stripped_len = len(document.text_before_cursor) - len(text)
|
45
|
+
|
46
|
+
if " " in text:
|
47
|
+
second_term = None
|
48
|
+
tokens = text.split()
|
49
|
+
if len(tokens) > 1:
|
50
|
+
second_term = tokens[1]
|
51
|
+
if second_term:
|
52
|
+
completer = self.options.get(second_term)
|
53
|
+
|
54
|
+
if completer is not None:
|
55
|
+
first_term = tokens[0]
|
56
|
+
remaining_text = text[len(first_term) :].lstrip()
|
57
|
+
move_cursor = len(text) - len(remaining_text) + stripped_len
|
58
|
+
|
59
|
+
remaining_text = remaining_text[len(second_term) :].lstrip()
|
60
|
+
move_cursor = len(text) - len(remaining_text) + stripped_len
|
61
|
+
|
62
|
+
new_document = Document(
|
63
|
+
remaining_text,
|
64
|
+
cursor_position=document.cursor_position - move_cursor,
|
65
|
+
)
|
66
|
+
|
67
|
+
for c in completer.get_completions(new_document, complete_event):
|
68
|
+
yield c
|
69
|
+
else:
|
70
|
+
completer = WordCompleter(
|
71
|
+
list(self.options.keys()), ignore_case=self.ignore_case
|
72
|
+
)
|
73
|
+
for c in completer.get_completions(document, complete_event):
|
74
|
+
yield c
|
75
|
+
else:
|
76
|
+
for t in pg_table_names(self.namespace, self.pg_path):
|
77
|
+
yield Completion(t)
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import json
|
2
1
|
import os
|
3
2
|
import re
|
4
3
|
import time
|
@@ -17,7 +16,6 @@ from adam.k8s_utils.kube_context import KubeContext
|
|
17
16
|
from adam.k8s_utils.statefulsets import StatefulSets
|
18
17
|
from adam.log import Log
|
19
18
|
from adam.repl_commands import ReplCommands
|
20
|
-
from adam.repl_completer import CompleterContext, ReplCompleter
|
21
19
|
from adam.repl_session import ReplSession
|
22
20
|
from adam.repl_state import ReplState
|
23
21
|
from adam.utils import deep_merge_dicts, deep_sort_dict, lines_to_tabular, log2
|
@@ -94,7 +92,7 @@ def enter_repl(state: ReplState):
|
|
94
92
|
sorted_cmds = sorted(cmd_list, key=lambda cmd: cmd.command())
|
95
93
|
while True:
|
96
94
|
try:
|
97
|
-
completer =
|
95
|
+
completer = NestedCompleter.from_nested_dict({})
|
98
96
|
if not state.bash_session:
|
99
97
|
completions = {}
|
100
98
|
# app commands are available only on a: drive
|
@@ -110,7 +108,7 @@ def enter_repl(state: ReplState):
|
|
110
108
|
log2(f'Timing auto-completion-calc {cmd.command()}: {time.time() - s1:.2f}')
|
111
109
|
|
112
110
|
# print(json.dumps(completions, indent=4))
|
113
|
-
completer =
|
111
|
+
completer = NestedCompleter.from_nested_dict(completions)
|
114
112
|
|
115
113
|
cmd = session.prompt(prompt_msg(), completer=completer, key_bindings=kb)
|
116
114
|
s0 = time.time()
|
@@ -154,7 +152,6 @@ def enter_repl(state: ReplState):
|
|
154
152
|
log2(e)
|
155
153
|
Config().debug(traceback.format_exc())
|
156
154
|
finally:
|
157
|
-
CompleterContext().reset()
|
158
155
|
Config().clear_wait_log_flag()
|
159
156
|
if Config().get('debugs.timings', False) and 'cmd' in locals() and 's0' in locals():
|
160
157
|
log2(f'Timing command {cmd}: {time.time() - s0:.2f}')
|
@@ -10,10 +10,10 @@ adam/config.py
|
|
10
10
|
adam/embedded_apps.py
|
11
11
|
adam/embedded_params.py
|
12
12
|
adam/log.py
|
13
|
+
adam/pg_table_completer.py
|
13
14
|
adam/pod_exec_result.py
|
14
15
|
adam/repl.py
|
15
16
|
adam/repl_commands.py
|
16
|
-
adam/repl_completer.py
|
17
17
|
adam/repl_session.py
|
18
18
|
adam/repl_state.py
|
19
19
|
adam/utils.py
|
@@ -108,6 +108,7 @@ adam/commands/medusa/medusa_show_backupjobs.py
|
|
108
108
|
adam/commands/medusa/medusa_show_restorejobs.py
|
109
109
|
adam/commands/postgres/__init__.py
|
110
110
|
adam/commands/postgres/postgres.py
|
111
|
+
adam/commands/postgres/postgres_completions.py
|
111
112
|
adam/commands/postgres/postgres_ls.py
|
112
113
|
adam/commands/postgres/postgres_preview.py
|
113
114
|
adam/commands/postgres/postgres_session.py
|
@@ -1,74 +0,0 @@
|
|
1
|
-
import re
|
2
|
-
|
3
|
-
from typing import Iterable
|
4
|
-
from prompt_toolkit.completion import CompleteEvent, Completion, NestedCompleter, WordCompleter
|
5
|
-
from prompt_toolkit.document import Document
|
6
|
-
|
7
|
-
from adam.commands.postgres.postgres_utils import pg_table_names
|
8
|
-
|
9
|
-
class CompleterContext:
|
10
|
-
# the singleton pattern
|
11
|
-
def __new__(cls, *args, **kwargs):
|
12
|
-
if not hasattr(cls, 'instance'): cls.instance = super(CompleterContext, cls).__new__(cls)
|
13
|
-
|
14
|
-
return cls.instance
|
15
|
-
|
16
|
-
def __init__(self):
|
17
|
-
if not hasattr(self, 'table_resolver'):
|
18
|
-
self.table_resolver = None
|
19
|
-
self.tables = []
|
20
|
-
|
21
|
-
def produce(self, word: str):
|
22
|
-
if match := re.match(r'^<pg_tables:(.*?):(.*?)>$', word):
|
23
|
-
self.table_resolver = word
|
24
|
-
self.tables = pg_table_names(match.group(1), match.group(2))
|
25
|
-
|
26
|
-
return self.tables
|
27
|
-
|
28
|
-
return None
|
29
|
-
|
30
|
-
def is_table(self, word: str):
|
31
|
-
if word in self.tables and self.table_resolver:
|
32
|
-
return self.table_resolver
|
33
|
-
|
34
|
-
return None
|
35
|
-
|
36
|
-
def reset(self):
|
37
|
-
self.table_resolver = None
|
38
|
-
self.tables = []
|
39
|
-
|
40
|
-
|
41
|
-
class ReplCompleter(NestedCompleter):
|
42
|
-
def get_completions(
|
43
|
-
self, document: Document, complete_event: CompleteEvent
|
44
|
-
) -> Iterable[Completion]:
|
45
|
-
text = document.text_before_cursor.lstrip()
|
46
|
-
stripped_len = len(document.text_before_cursor) - len(text)
|
47
|
-
|
48
|
-
if " " in text:
|
49
|
-
first_term = text.split()[0]
|
50
|
-
completer = self.options.get(first_term)
|
51
|
-
if table_resolver := CompleterContext().is_table(first_term):
|
52
|
-
completer = self.options.get(table_resolver)
|
53
|
-
|
54
|
-
if completer is not None:
|
55
|
-
remaining_text = text[len(first_term) :].lstrip()
|
56
|
-
move_cursor = len(text) - len(remaining_text) + stripped_len
|
57
|
-
|
58
|
-
new_document = Document(
|
59
|
-
remaining_text,
|
60
|
-
cursor_position=document.cursor_position - move_cursor,
|
61
|
-
)
|
62
|
-
|
63
|
-
for c in completer.get_completions(new_document, complete_event):
|
64
|
-
if words := CompleterContext().produce(c.text):
|
65
|
-
for w in words:
|
66
|
-
yield Completion(w)
|
67
|
-
else:
|
68
|
-
yield c
|
69
|
-
else:
|
70
|
-
completer = WordCompleter(
|
71
|
-
list(self.options.keys()), ignore_case=self.ignore_case
|
72
|
-
)
|
73
|
-
for c in completer.get_completions(document, complete_event):
|
74
|
-
yield c
|
kaqing-2.0.43/adam/version.py
DELETED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|