kaqing 2.0.49__tar.gz → 2.0.50__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.49 → kaqing-2.0.50}/PKG-INFO +1 -1
- kaqing-2.0.50/adam/commands/cql/cql_completions.py +13 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/cql/cql_table_completer.py +4 -4
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/cql/cqlsh.py +1 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/medusa/medusa_restore.py +1 -2
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/postgres/postgres.py +3 -2
- kaqing-2.0.50/adam/commands/postgres/psql_completions.py +11 -0
- kaqing-2.0.50/adam/commands/postgres/psql_table_completer.py +18 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/preview_table.py +4 -4
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/repl.py +2 -1
- kaqing-2.0.49/adam/table_completer.py → kaqing-2.0.50/adam/sql/any_completer.py +23 -32
- kaqing-2.0.50/adam/sql/sql_completer.py +53 -0
- kaqing-2.0.50/adam/sql/sql_utils.py +5 -0
- kaqing-2.0.50/adam/sql/table_name_completer.py +17 -0
- kaqing-2.0.50/adam/sso/__init__.py +0 -0
- kaqing-2.0.50/adam/version.py +5 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/kaqing.egg-info/PKG-INFO +1 -1
- {kaqing-2.0.49 → kaqing-2.0.50}/kaqing.egg-info/SOURCES.txt +7 -3
- {kaqing-2.0.49 → kaqing-2.0.50}/setup.py +1 -1
- kaqing-2.0.49/adam/commands/cql/cql_completions.py +0 -12
- kaqing-2.0.49/adam/commands/postgres/pg_completions.py +0 -9
- kaqing-2.0.49/adam/commands/postgres/pg_table_completer.py +0 -18
- kaqing-2.0.49/adam/version.py +0 -5
- {kaqing-2.0.49 → kaqing-2.0.50}/README +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/__init__.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/app_session.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/apps.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/batch.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/checks/__init__.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/checks/check.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/checks/check_context.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/checks/check_result.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/checks/check_utils.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/checks/compactionstats.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/checks/cpu.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/checks/disk.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/checks/gossip.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/checks/issue.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/checks/memory.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/checks/status.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/cli.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/cli_group.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/__init__.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/column.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/columns.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/compactions.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/cpu.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/dir_data.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/dir_snapshots.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/gossip.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/host_id.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/memory.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/node_address.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/node_load.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/node_owns.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/node_status.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/node_tokens.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/node_utils.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/pod_name.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/volume_cassandra.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/columns/volume_root.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/__init__.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/alter_tables.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/app.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/app_ping.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/bash.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/cd.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/check.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/cli_commands.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/command.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/command_helpers.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/commands_utils.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/cp.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/cql/__init__.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/cql/cql_utils.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/deploy/__init__.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/deploy/code_start.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/deploy/code_stop.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/deploy/code_utils.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/deploy/deploy.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/deploy/deploy_frontend.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/deploy/deploy_pg_agent.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/deploy/deploy_pod.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/deploy/deploy_utils.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/deploy/undeploy.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/deploy/undeploy_frontend.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/deploy/undeploy_pg_agent.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/deploy/undeploy_pod.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/describe/__init__.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/describe/describe.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/describe/describe_keyspace.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/describe/describe_keyspaces.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/describe/describe_table.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/describe/describe_tables.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/devices.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/exit.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/help.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/issues.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/login.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/logs.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/ls.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/medusa/__init__.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/medusa/medusa.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/medusa/medusa_backup.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/medusa/medusa_show_backupjobs.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/medusa/medusa_show_restorejobs.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/nodetool.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/nodetool_commands.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/param_get.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/param_set.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/postgres/__init__.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/postgres/postgres_ls.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/postgres/postgres_preview.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/postgres/postgres_session.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/postgres/postgres_utils.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/pwd.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/reaper/__init__.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/reaper/reaper.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/reaper/reaper_forward.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/reaper/reaper_forward_stop.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/reaper/reaper_restart.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/reaper/reaper_run_abort.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/reaper/reaper_runs.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/reaper/reaper_runs_abort.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/reaper/reaper_schedule_activate.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/reaper/reaper_schedule_start.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/reaper/reaper_schedule_stop.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/reaper/reaper_schedules.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/reaper/reaper_session.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/reaper/reaper_status.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/repair/__init__.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/repair/repair.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/repair/repair_log.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/repair/repair_run.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/repair/repair_scan.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/repair/repair_stop.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/report.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/restart.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/rollout.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/shell.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/show/__init__.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/show/show.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/show/show_adam.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/show/show_app_actions.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/show/show_app_id.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/show/show_app_queues.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/show/show_cassandra_status.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/show/show_cassandra_version.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/show/show_commands.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/show/show_login.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/show/show_params.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/show/show_processes.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/show/show_repairs.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/show/show_storage.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/commands/watch.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/config.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/embedded_apps.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/embedded_params.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/k8s_utils/__init__.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/k8s_utils/cassandra_clusters.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/k8s_utils/cassandra_nodes.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/k8s_utils/config_maps.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/k8s_utils/custom_resources.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/k8s_utils/deployment.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/k8s_utils/ingresses.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/k8s_utils/jobs.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/k8s_utils/kube_context.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/k8s_utils/pods.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/k8s_utils/secrets.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/k8s_utils/service_accounts.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/k8s_utils/services.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/k8s_utils/statefulsets.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/k8s_utils/volumes.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/log.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/pod_exec_result.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/repl_commands.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/repl_session.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/repl_state.py +0 -0
- {kaqing-2.0.49/adam/sso → kaqing-2.0.50/adam/sql}/__init__.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/sso/authenticator.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/sso/authn_ad.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/sso/authn_okta.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/sso/cred_cache.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/sso/id_token.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/sso/idp.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/sso/idp_login.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/sso/idp_session.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/sso/sso_config.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/adam/utils.py +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/kaqing.egg-info/dependency_links.txt +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/kaqing.egg-info/entry_points.txt +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/kaqing.egg-info/top_level.txt +0 -0
- {kaqing-2.0.49 → kaqing-2.0.50}/setup.cfg +0 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
from adam.commands.cql.cql_table_completer import CqlTableNameCompleter
|
2
|
+
from adam.commands.cql.cql_utils import table_names
|
3
|
+
from adam.repl_state import ReplState
|
4
|
+
from adam.sql.sql_completer import SqlCompleter
|
5
|
+
|
6
|
+
def cql_completions(state: ReplState) -> dict[str, any]:
|
7
|
+
table_name_completer = CqlTableNameCompleter(table_names(state))
|
8
|
+
return {
|
9
|
+
'describe': {
|
10
|
+
'keyspaces': None,
|
11
|
+
'table': table_name_completer,
|
12
|
+
'tables': None},
|
13
|
+
} | SqlCompleter.completions(table_name_completer)
|
@@ -1,6 +1,6 @@
|
|
1
|
-
from adam.
|
1
|
+
from adam.sql.table_name_completer import NestedDict, TableNameCompleter
|
2
2
|
|
3
|
-
class
|
3
|
+
class CqlTableNameCompleter(TableNameCompleter):
|
4
4
|
def __init__(self, tables: list[str], nested_dict: NestedDict = {}, ignore_case: bool = True):
|
5
5
|
self._tables = tables
|
6
6
|
self.ignore_case = ignore_case
|
@@ -9,8 +9,8 @@ class CqlTableCompleter(TableCompleter):
|
|
9
9
|
def __repr__(self) -> str:
|
10
10
|
return "CqlTableCompleter(%r)" % (len(self._tables))
|
11
11
|
|
12
|
-
def nested(self, data: NestedDict) -> '
|
13
|
-
return
|
12
|
+
def nested(self, data: NestedDict) -> 'TableNameCompleter':
|
13
|
+
return CqlTableNameCompleter(self._tables).append_nested_dict(data)
|
14
14
|
|
15
15
|
def tables(self) -> list[str]:
|
16
16
|
return self._tables
|
@@ -59,8 +59,7 @@ class MedusaRestore(Command):
|
|
59
59
|
now_dtformat = datetime.now().strftime("%Y-%m-%d.%H.%M.%S")
|
60
60
|
rtname = 'medusa-' + now_dtformat + '-restore-from-' + bkname
|
61
61
|
try:
|
62
|
-
|
63
|
-
# CustomResources.create_medusa_restorejob(rtname, bkname, dc, ns)
|
62
|
+
CustomResources.create_medusa_restorejob(rtname, bkname, dc, ns)
|
64
63
|
except Exception as e:
|
65
64
|
log2("Exception: MedusaRestore failed: %s\n" % e)
|
66
65
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import click
|
2
2
|
|
3
3
|
from adam.commands.command import Command
|
4
|
-
from adam.commands.postgres.
|
4
|
+
from adam.commands.postgres.psql_completions import psql_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
|
@@ -66,13 +66,14 @@ class Postgres(Command):
|
|
66
66
|
|
67
67
|
def completion(self, state: ReplState):
|
68
68
|
if state.device != state.P:
|
69
|
+
# conflicts with cql completions
|
69
70
|
return {}
|
70
71
|
|
71
72
|
leaf = {}
|
72
73
|
session = PostgresSession(state.namespace, state.pg_path)
|
73
74
|
if session.db:
|
74
75
|
if pg_table_names(state.namespace, state.pg_path):
|
75
|
-
leaf =
|
76
|
+
leaf = psql_completions(state.namespace, state.pg_path)
|
76
77
|
elif state.pg_path:
|
77
78
|
leaf = {
|
78
79
|
'\h': None,
|
@@ -0,0 +1,11 @@
|
|
1
|
+
from adam.commands.postgres.psql_table_completer import PsqlTableNameCompleter
|
2
|
+
from adam.sql.sql_completer import SqlCompleter
|
3
|
+
|
4
|
+
def psql_completions(ns: str, pg_path: str):
|
5
|
+
return {
|
6
|
+
'\h': None,
|
7
|
+
'\d': None,
|
8
|
+
'\dt': None,
|
9
|
+
'\du': None
|
10
|
+
} | SqlCompleter.completions(PsqlTableNameCompleter(ns, pg_path))
|
11
|
+
# } | PsqlTableCompleter(ns, pg_path).completions()
|
@@ -0,0 +1,18 @@
|
|
1
|
+
from adam.commands.postgres.postgres_utils import pg_table_names
|
2
|
+
from adam.sql.table_name_completer import NestedDict, TableNameCompleter
|
3
|
+
|
4
|
+
class PsqlTableNameCompleter(TableNameCompleter):
|
5
|
+
def __init__(self, namespace: str, pg_path: str, nested_dict: NestedDict = {}, ignore_case: bool = True):
|
6
|
+
self.namespace = namespace
|
7
|
+
self.pg_path = pg_path
|
8
|
+
self.ignore_case = ignore_case
|
9
|
+
self.append_nested_dict(nested_dict)
|
10
|
+
|
11
|
+
def __repr__(self) -> str:
|
12
|
+
return "PsqlTableCompleter(%r, pg_path=%r)" % (self.namespace, self.pg_path)
|
13
|
+
|
14
|
+
def nested(self, data: NestedDict) -> 'TableNameCompleter':
|
15
|
+
return PsqlTableNameCompleter(self.namespace, self.pg_path).append_nested_dict(data)
|
16
|
+
|
17
|
+
def tables(self) -> list[str]:
|
18
|
+
return pg_table_names(self.namespace, self.pg_path)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import functools
|
2
2
|
|
3
3
|
from adam.commands.command import Command
|
4
|
-
from adam.commands.cql.cql_table_completer import
|
4
|
+
from adam.commands.cql.cql_table_completer import CqlTableNameCompleter
|
5
5
|
from adam.commands.cql.cql_utils import run_cql, table_names, tables
|
6
|
-
from adam.commands.postgres.
|
6
|
+
from adam.commands.postgres.psql_table_completer import PsqlTableNameCompleter
|
7
7
|
from adam.commands.postgres.postgres_session import PostgresSession
|
8
8
|
from adam.config import Config
|
9
9
|
from adam.repl_state import ReplState, RequiredState
|
@@ -73,9 +73,9 @@ class PreviewTable(Command):
|
|
73
73
|
|
74
74
|
def completion(self, state: ReplState):
|
75
75
|
if state.device == ReplState.P:
|
76
|
-
return {PreviewTable.COMMAND:
|
76
|
+
return {PreviewTable.COMMAND: PsqlTableNameCompleter(state.namespace, state.pg_path)}
|
77
77
|
elif state.sts:
|
78
|
-
return {PreviewTable.COMMAND:
|
78
|
+
return {PreviewTable.COMMAND: CqlTableNameCompleter(table_names(state))}
|
79
79
|
|
80
80
|
return {}
|
81
81
|
|
@@ -18,6 +18,7 @@ from adam.log import Log
|
|
18
18
|
from adam.repl_commands import ReplCommands
|
19
19
|
from adam.repl_session import ReplSession
|
20
20
|
from adam.repl_state import ReplState
|
21
|
+
from adam.sql.sql_completer import SqlCompleter
|
21
22
|
from adam.utils import deep_merge_dicts, deep_sort_dict, lines_to_tabular, log2
|
22
23
|
from adam.apps import Apps
|
23
24
|
from . import __version__
|
@@ -108,7 +109,7 @@ def enter_repl(state: ReplState):
|
|
108
109
|
log2(f'Timing auto-completion-calc {cmd.command()}: {time.time() - s1:.2f}')
|
109
110
|
|
110
111
|
# print(json.dumps(completions, indent=4))
|
111
|
-
completer =
|
112
|
+
completer = SqlCompleter.from_nested_dict(completions)
|
112
113
|
|
113
114
|
cmd = session.prompt(prompt_msg(), completer=completer, key_bindings=kb)
|
114
115
|
s0 = time.time()
|
@@ -1,16 +1,18 @@
|
|
1
|
-
from abc import abstractmethod
|
2
1
|
from typing import Any, Dict, Iterable, Mapping, Optional, Set, Union
|
3
2
|
from prompt_toolkit.completion import CompleteEvent, Completer, Completion, NestedCompleter, WordCompleter
|
4
3
|
from prompt_toolkit.document import Document
|
5
4
|
|
5
|
+
from adam.sql.sql_utils import safe_terms
|
6
|
+
|
6
7
|
NestedDict = Mapping[str, Union[Any, Set[str], None, Completer]]
|
7
8
|
|
8
|
-
class
|
9
|
-
def __init__(self, nested_dict: NestedDict = {}, ignore_case: bool = True):
|
9
|
+
class AnyCompleter(Completer):
|
10
|
+
def __init__(self, default: str = None, nested_dict: NestedDict = {}, ignore_case: bool = True):
|
11
|
+
self.default = default
|
10
12
|
self.ignore_case = ignore_case
|
11
13
|
self.append_nested_dict(nested_dict)
|
12
14
|
|
13
|
-
def append_nested_dict(self, data: NestedDict) -> "
|
15
|
+
def append_nested_dict(self, data: NestedDict) -> "AnyCompleter":
|
14
16
|
options: Dict[str, Optional[Completer]] = {}
|
15
17
|
for key, value in data.items():
|
16
18
|
if isinstance(value, Completer):
|
@@ -33,18 +35,18 @@ class TableCompleter(Completer):
|
|
33
35
|
text = document.text_before_cursor.lstrip()
|
34
36
|
stripped_len = len(document.text_before_cursor) - len(text)
|
35
37
|
|
36
|
-
|
38
|
+
terms, has_space = safe_terms(text)
|
39
|
+
if has_space:
|
37
40
|
second_term = None
|
38
|
-
|
39
|
-
|
40
|
-
second_term = tokens[1]
|
41
|
+
if len(terms) > 1:
|
42
|
+
second_term = terms[1]
|
41
43
|
|
42
44
|
yielded = False
|
43
45
|
if second_term:
|
44
46
|
completer = self.options.get(second_term)
|
45
47
|
|
46
48
|
if completer is not None:
|
47
|
-
first_term =
|
49
|
+
first_term = terms[0]
|
48
50
|
remaining_text = text[len(first_term) :].lstrip()
|
49
51
|
move_cursor = len(text) - len(remaining_text) + stripped_len
|
50
52
|
|
@@ -66,28 +68,17 @@ class TableCompleter(Completer):
|
|
66
68
|
)
|
67
69
|
for c in completer.get_completions(document, complete_event):
|
68
70
|
yield c
|
69
|
-
|
70
|
-
|
71
|
-
self.tables(), ignore_case=self.ignore_case
|
72
|
-
)
|
73
|
-
for c in completer.get_completions(document, complete_event):
|
71
|
+
elif words := self.words():
|
72
|
+
for c in words.get_completions(document, complete_event):
|
74
73
|
yield c
|
75
74
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
def
|
85
|
-
return
|
86
|
-
'delete': {'from': self.nested({'where': {'id': {'=': {"'id'": None}}}})},
|
87
|
-
'insert': {'into': self.nested({'values(': None})},
|
88
|
-
'select': {'*': {'from': self.nested({
|
89
|
-
'limit': {'1': {'where': {'id': {'=': {"'id'": None}}}}},
|
90
|
-
'where': {'id': {'=': {"'id'": {'limit': {'1': None}}}}}
|
91
|
-
})}},
|
92
|
-
'update': self.nested({'set': {'column': {'=': None}}}),
|
93
|
-
}
|
75
|
+
def words(self):
|
76
|
+
if not self.default:
|
77
|
+
return None
|
78
|
+
|
79
|
+
return WordCompleter(
|
80
|
+
[self.default], ignore_case=self.ignore_case
|
81
|
+
)
|
82
|
+
|
83
|
+
def nested(self, data: NestedDict) -> 'AnyCompleter':
|
84
|
+
return AnyCompleter(self.default).append_nested_dict(data)
|
@@ -0,0 +1,53 @@
|
|
1
|
+
from typing import Dict, Iterable, Optional
|
2
|
+
from prompt_toolkit.completion import CompleteEvent, Completer, Completion, NestedCompleter, WordCompleter
|
3
|
+
from prompt_toolkit.document import Document
|
4
|
+
|
5
|
+
from adam.sql.any_completer import AnyCompleter as any
|
6
|
+
from adam.sql.sql_utils import safe_terms
|
7
|
+
from adam.sql.table_name_completer import TableNameCompleter
|
8
|
+
|
9
|
+
class SqlCompleter(NestedCompleter):
|
10
|
+
def __init__(
|
11
|
+
self, options: Dict[str, Optional[Completer]], ignore_case: bool = True
|
12
|
+
) -> None:
|
13
|
+
super().__init__(options, ignore_case)
|
14
|
+
|
15
|
+
def get_completions(
|
16
|
+
self, document: Document, complete_event: CompleteEvent
|
17
|
+
) -> Iterable[Completion]:
|
18
|
+
text = document.text_before_cursor.lstrip()
|
19
|
+
stripped_len = len(document.text_before_cursor) - len(text)
|
20
|
+
|
21
|
+
terms, has_space = safe_terms(text)
|
22
|
+
if has_space:
|
23
|
+
first_term = terms[0]
|
24
|
+
completer = self.options.get(first_term)
|
25
|
+
|
26
|
+
if completer is not None:
|
27
|
+
remaining_text = text[len(first_term) :].lstrip()
|
28
|
+
move_cursor = len(text) - len(remaining_text) + stripped_len
|
29
|
+
|
30
|
+
new_document = Document(
|
31
|
+
remaining_text,
|
32
|
+
cursor_position=document.cursor_position - move_cursor,
|
33
|
+
)
|
34
|
+
|
35
|
+
for c in completer.get_completions(new_document, complete_event):
|
36
|
+
yield c
|
37
|
+
else:
|
38
|
+
completer = WordCompleter(
|
39
|
+
list(self.options.keys()), ignore_case=self.ignore_case
|
40
|
+
)
|
41
|
+
for c in completer.get_completions(document, complete_event):
|
42
|
+
yield c
|
43
|
+
|
44
|
+
def completions(table: TableNameCompleter):
|
45
|
+
return {
|
46
|
+
'delete': {'from': table.nested({'where': any('id').nested({'=': any("'id'")})})},
|
47
|
+
'insert': {'into': table.nested({'values(': None})},
|
48
|
+
'select': any('*').nested({'from': table.nested({
|
49
|
+
'limit': any('1'),
|
50
|
+
'where': any('id').nested({'=': any("'id'").nested({'limit': any('1')})})
|
51
|
+
})}),
|
52
|
+
'update': table.nested({'set': {'column': {'=': None}}}),
|
53
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
from abc import abstractmethod
|
2
|
+
from prompt_toolkit.completion import WordCompleter
|
3
|
+
|
4
|
+
from .any_completer import AnyCompleter, NestedDict
|
5
|
+
|
6
|
+
class TableNameCompleter(AnyCompleter):
|
7
|
+
def __init__(self, nested_dict: NestedDict = {}, ignore_case: bool = True):
|
8
|
+
super().__init__(nested_dict=nested_dict, ignore_case=ignore_case)
|
9
|
+
|
10
|
+
def words(self):
|
11
|
+
return WordCompleter(
|
12
|
+
self.tables(), ignore_case=self.ignore_case
|
13
|
+
)
|
14
|
+
|
15
|
+
@abstractmethod
|
16
|
+
def tables(self) -> list[str]:
|
17
|
+
pass
|
File without changes
|
@@ -15,7 +15,6 @@ adam/repl.py
|
|
15
15
|
adam/repl_commands.py
|
16
16
|
adam/repl_session.py
|
17
17
|
adam/repl_state.py
|
18
|
-
adam/table_completer.py
|
19
18
|
adam/utils.py
|
20
19
|
adam/version.py
|
21
20
|
adam/checks/__init__.py
|
@@ -110,13 +109,13 @@ adam/commands/medusa/medusa_restore.py
|
|
110
109
|
adam/commands/medusa/medusa_show_backupjobs.py
|
111
110
|
adam/commands/medusa/medusa_show_restorejobs.py
|
112
111
|
adam/commands/postgres/__init__.py
|
113
|
-
adam/commands/postgres/pg_completions.py
|
114
|
-
adam/commands/postgres/pg_table_completer.py
|
115
112
|
adam/commands/postgres/postgres.py
|
116
113
|
adam/commands/postgres/postgres_ls.py
|
117
114
|
adam/commands/postgres/postgres_preview.py
|
118
115
|
adam/commands/postgres/postgres_session.py
|
119
116
|
adam/commands/postgres/postgres_utils.py
|
117
|
+
adam/commands/postgres/psql_completions.py
|
118
|
+
adam/commands/postgres/psql_table_completer.py
|
120
119
|
adam/commands/reaper/__init__.py
|
121
120
|
adam/commands/reaper/reaper.py
|
122
121
|
adam/commands/reaper/reaper_forward.py
|
@@ -166,6 +165,11 @@ adam/k8s_utils/service_accounts.py
|
|
166
165
|
adam/k8s_utils/services.py
|
167
166
|
adam/k8s_utils/statefulsets.py
|
168
167
|
adam/k8s_utils/volumes.py
|
168
|
+
adam/sql/__init__.py
|
169
|
+
adam/sql/any_completer.py
|
170
|
+
adam/sql/sql_completer.py
|
171
|
+
adam/sql/sql_utils.py
|
172
|
+
adam/sql/table_name_completer.py
|
169
173
|
adam/sso/__init__.py
|
170
174
|
adam/sso/authenticator.py
|
171
175
|
adam/sso/authn_ad.py
|
@@ -1,12 +0,0 @@
|
|
1
|
-
from adam.commands.cql.cql_table_completer import CqlTableCompleter
|
2
|
-
from adam.commands.cql.cql_utils import table_names
|
3
|
-
from adam.repl_state import ReplState
|
4
|
-
|
5
|
-
def cql_completions(state: ReplState) -> dict[str, any]:
|
6
|
-
completer = CqlTableCompleter(table_names(state))
|
7
|
-
return {
|
8
|
-
'describe': {
|
9
|
-
'keyspaces': None,
|
10
|
-
'table': completer.completions(),
|
11
|
-
'tables': None},
|
12
|
-
} | completer.completions()
|
@@ -1,18 +0,0 @@
|
|
1
|
-
from adam.commands.postgres.postgres_utils import pg_table_names
|
2
|
-
from adam.table_completer import NestedDict, TableCompleter
|
3
|
-
|
4
|
-
class PgTableCompleter(TableCompleter):
|
5
|
-
def __init__(self, namespace: str, pg_path: str, nested_dict: NestedDict = {}, ignore_case: bool = True):
|
6
|
-
self.namespace = namespace
|
7
|
-
self.pg_path = pg_path
|
8
|
-
self.ignore_case = ignore_case
|
9
|
-
self.append_nested_dict(nested_dict)
|
10
|
-
|
11
|
-
def __repr__(self) -> str:
|
12
|
-
return "PgTableCompleter(%r, pg_path=%r)" % (self.namespace, self.pg_path)
|
13
|
-
|
14
|
-
def nested(self, data: NestedDict) -> 'TableCompleter':
|
15
|
-
return PgTableCompleter(self.namespace, self.pg_path).append_nested_dict(data)
|
16
|
-
|
17
|
-
def tables(self) -> list[str]:
|
18
|
-
return pg_table_names(self.namespace, self.pg_path)
|
kaqing-2.0.49/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
|