kaqing 1.77.0__py3-none-any.whl → 2.0.171__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.
- adam/__init__.py +1 -0
- adam/app_session.py +182 -0
- {walker → adam}/apps.py +8 -24
- {walker → adam}/batch.py +54 -97
- {walker → adam}/checks/check.py +3 -3
- {walker → adam}/checks/check_result.py +1 -1
- adam/checks/check_utils.py +65 -0
- {walker → adam}/checks/compactionstats.py +6 -6
- {walker → adam}/checks/cpu.py +14 -8
- adam/checks/cpu_metrics.py +52 -0
- {walker → adam}/checks/disk.py +6 -6
- {walker → adam}/checks/gossip.py +5 -5
- {walker → adam}/checks/memory.py +7 -7
- {walker → adam}/checks/status.py +5 -5
- {walker → adam}/cli.py +3 -3
- {walker → adam}/columns/column.py +1 -1
- adam/columns/columns.py +45 -0
- {walker → adam}/columns/compactions.py +5 -5
- {walker → adam}/columns/cpu.py +6 -4
- adam/columns/cpu_metrics.py +22 -0
- {walker → adam}/columns/dir_data.py +3 -3
- {walker → adam}/columns/dir_snapshots.py +3 -3
- {walker → adam}/columns/gossip.py +5 -5
- {walker → adam}/columns/host_id.py +3 -3
- {walker → adam}/columns/memory.py +3 -3
- {walker → adam}/columns/node_address.py +3 -3
- {walker → adam}/columns/node_load.py +3 -3
- {walker → adam}/columns/node_owns.py +3 -3
- {walker → adam}/columns/node_status.py +3 -3
- {walker → adam}/columns/node_tokens.py +3 -3
- {walker → adam}/columns/node_utils.py +2 -2
- {walker → adam}/columns/pod_name.py +2 -2
- {walker → adam}/columns/volume_cassandra.py +4 -4
- {walker → adam}/columns/volume_root.py +3 -3
- adam/commands/__init__.py +15 -0
- adam/commands/alter_tables.py +81 -0
- adam/commands/app_cmd.py +38 -0
- {walker → adam}/commands/app_ping.py +10 -16
- adam/commands/audit/audit.py +84 -0
- adam/commands/audit/audit_repair_tables.py +74 -0
- adam/commands/audit/audit_run.py +50 -0
- adam/commands/audit/show_last10.py +48 -0
- adam/commands/audit/show_slow10.py +47 -0
- adam/commands/audit/show_top10.py +45 -0
- adam/commands/audit/utils_show_top10.py +59 -0
- adam/commands/bash/__init__.py +5 -0
- adam/commands/bash/bash.py +36 -0
- adam/commands/bash/bash_completer.py +93 -0
- adam/commands/bash/utils_bash.py +16 -0
- adam/commands/cat.py +50 -0
- adam/commands/cd.py +43 -0
- adam/commands/check.py +73 -0
- {walker → adam}/commands/cli_commands.py +7 -8
- adam/commands/code.py +57 -0
- adam/commands/command.py +190 -0
- {walker → adam}/commands/command_helpers.py +1 -1
- {walker → adam}/commands/commands_utils.py +15 -25
- adam/commands/cp.py +89 -0
- adam/commands/cql/cql_completions.py +33 -0
- {walker/commands → adam/commands/cql}/cqlsh.py +20 -35
- adam/commands/cql/utils_cql.py +343 -0
- {walker/commands/frontend → adam/commands/deploy}/code_start.py +11 -14
- adam/commands/deploy/code_stop.py +40 -0
- {walker/commands/frontend → adam/commands/deploy}/code_utils.py +7 -9
- adam/commands/deploy/deploy.py +25 -0
- adam/commands/deploy/deploy_frontend.py +49 -0
- adam/commands/deploy/deploy_pg_agent.py +35 -0
- adam/commands/deploy/deploy_pod.py +108 -0
- adam/commands/deploy/deploy_utils.py +29 -0
- adam/commands/deploy/undeploy.py +25 -0
- adam/commands/deploy/undeploy_frontend.py +38 -0
- adam/commands/deploy/undeploy_pg_agent.py +39 -0
- adam/commands/deploy/undeploy_pod.py +48 -0
- adam/commands/devices/device.py +118 -0
- adam/commands/devices/device_app.py +173 -0
- adam/commands/devices/device_auit_log.py +49 -0
- adam/commands/devices/device_cass.py +185 -0
- adam/commands/devices/device_export.py +86 -0
- adam/commands/devices/device_postgres.py +144 -0
- adam/commands/devices/devices.py +25 -0
- {walker → adam}/commands/exit.py +3 -6
- adam/commands/export/clean_up_all_export_sessions.py +37 -0
- adam/commands/export/clean_up_export_sessions.py +51 -0
- adam/commands/export/drop_export_database.py +55 -0
- adam/commands/export/drop_export_databases.py +43 -0
- adam/commands/export/export.py +53 -0
- adam/commands/export/export_databases.py +170 -0
- adam/commands/export/export_handlers.py +71 -0
- adam/commands/export/export_select.py +81 -0
- adam/commands/export/export_select_x.py +54 -0
- adam/commands/export/export_use.py +52 -0
- adam/commands/export/exporter.py +352 -0
- adam/commands/export/import_session.py +40 -0
- adam/commands/export/importer.py +67 -0
- adam/commands/export/importer_athena.py +80 -0
- adam/commands/export/importer_sqlite.py +47 -0
- adam/commands/export/show_column_counts.py +54 -0
- adam/commands/export/show_export_databases.py +36 -0
- adam/commands/export/show_export_session.py +48 -0
- adam/commands/export/show_export_sessions.py +44 -0
- adam/commands/export/utils_export.py +314 -0
- {walker → adam}/commands/help.py +17 -12
- adam/commands/intermediate_command.py +49 -0
- adam/commands/issues.py +43 -0
- adam/commands/kubectl.py +38 -0
- adam/commands/login.py +70 -0
- {walker → adam}/commands/logs.py +8 -10
- adam/commands/ls.py +41 -0
- adam/commands/medusa/medusa.py +27 -0
- adam/commands/medusa/medusa_backup.py +57 -0
- adam/commands/medusa/medusa_restore.py +83 -0
- adam/commands/medusa/medusa_show_backupjobs.py +51 -0
- adam/commands/medusa/medusa_show_restorejobs.py +47 -0
- {walker → adam}/commands/nodetool.py +17 -21
- {walker → adam}/commands/param_get.py +15 -16
- adam/commands/param_set.py +43 -0
- adam/commands/postgres/postgres.py +104 -0
- adam/commands/postgres/postgres_context.py +274 -0
- {walker → adam}/commands/postgres/postgres_ls.py +7 -11
- {walker → adam}/commands/postgres/postgres_preview.py +8 -13
- adam/commands/postgres/psql_completions.py +10 -0
- adam/commands/postgres/utils_postgres.py +66 -0
- adam/commands/preview_table.py +37 -0
- adam/commands/pwd.py +47 -0
- adam/commands/reaper/reaper.py +35 -0
- adam/commands/reaper/reaper_forward.py +93 -0
- adam/commands/reaper/reaper_forward_session.py +6 -0
- {walker → adam}/commands/reaper/reaper_forward_stop.py +13 -19
- {walker → adam}/commands/reaper/reaper_restart.py +10 -17
- adam/commands/reaper/reaper_run_abort.py +46 -0
- adam/commands/reaper/reaper_runs.py +82 -0
- adam/commands/reaper/reaper_runs_abort.py +63 -0
- adam/commands/reaper/reaper_schedule_activate.py +45 -0
- adam/commands/reaper/reaper_schedule_start.py +45 -0
- adam/commands/reaper/reaper_schedule_stop.py +45 -0
- {walker → adam}/commands/reaper/reaper_schedules.py +6 -16
- {walker → adam}/commands/reaper/reaper_status.py +11 -19
- adam/commands/reaper/utils_reaper.py +196 -0
- adam/commands/repair/repair.py +26 -0
- {walker → adam}/commands/repair/repair_log.py +7 -10
- adam/commands/repair/repair_run.py +70 -0
- adam/commands/repair/repair_scan.py +71 -0
- {walker → adam}/commands/repair/repair_stop.py +8 -11
- adam/commands/report.py +61 -0
- adam/commands/restart.py +60 -0
- {walker → adam}/commands/rollout.py +25 -30
- adam/commands/shell.py +34 -0
- adam/commands/show/show.py +39 -0
- walker/commands/show/show_version.py → adam/commands/show/show_adam.py +14 -10
- adam/commands/show/show_app_actions.py +57 -0
- {walker → adam}/commands/show/show_app_id.py +12 -15
- {walker → adam}/commands/show/show_app_queues.py +9 -12
- adam/commands/show/show_cassandra_repairs.py +38 -0
- adam/commands/show/show_cassandra_status.py +124 -0
- {walker → adam}/commands/show/show_cassandra_version.py +6 -16
- adam/commands/show/show_commands.py +59 -0
- walker/commands/show/show_storage.py → adam/commands/show/show_host.py +11 -13
- adam/commands/show/show_login.py +62 -0
- {walker → adam}/commands/show/show_params.py +4 -4
- adam/commands/show/show_processes.py +51 -0
- adam/commands/show/show_storage.py +42 -0
- adam/commands/watch.py +82 -0
- {walker → adam}/config.py +10 -22
- {walker → adam}/embedded_apps.py +1 -1
- adam/embedded_params.py +2 -0
- adam/log.py +47 -0
- {walker → adam}/pod_exec_result.py +10 -2
- adam/repl.py +182 -0
- adam/repl_commands.py +124 -0
- adam/repl_state.py +458 -0
- adam/sql/__init__.py +0 -0
- adam/sql/sql_completer.py +120 -0
- adam/sql/sql_state_machine.py +618 -0
- adam/sql/term_completer.py +76 -0
- adam/sso/__init__.py +0 -0
- {walker → adam}/sso/authenticator.py +5 -1
- adam/sso/authn_ad.py +170 -0
- {walker → adam}/sso/authn_okta.py +39 -22
- adam/sso/cred_cache.py +60 -0
- adam/sso/id_token.py +23 -0
- adam/sso/idp.py +143 -0
- adam/sso/idp_login.py +50 -0
- adam/sso/idp_session.py +55 -0
- adam/sso/sso_config.py +63 -0
- adam/utils.py +679 -0
- adam/utils_app.py +98 -0
- adam/utils_athena.py +145 -0
- adam/utils_audits.py +106 -0
- adam/utils_issues.py +32 -0
- adam/utils_k8s/__init__.py +0 -0
- adam/utils_k8s/app_clusters.py +28 -0
- adam/utils_k8s/app_pods.py +33 -0
- adam/utils_k8s/cassandra_clusters.py +36 -0
- adam/utils_k8s/cassandra_nodes.py +33 -0
- adam/utils_k8s/config_maps.py +34 -0
- {walker/k8s_utils → adam/utils_k8s}/custom_resources.py +7 -2
- adam/utils_k8s/deployment.py +56 -0
- {walker/k8s_utils → adam/utils_k8s}/ingresses.py +3 -4
- {walker/k8s_utils → adam/utils_k8s}/jobs.py +3 -3
- adam/utils_k8s/k8s.py +87 -0
- {walker/k8s_utils → adam/utils_k8s}/kube_context.py +4 -4
- adam/utils_k8s/pods.py +290 -0
- {walker/k8s_utils → adam/utils_k8s}/secrets.py +8 -4
- adam/utils_k8s/service_accounts.py +170 -0
- {walker/k8s_utils → adam/utils_k8s}/services.py +3 -4
- {walker/k8s_utils → adam/utils_k8s}/statefulsets.py +6 -16
- {walker/k8s_utils → adam/utils_k8s}/volumes.py +10 -1
- adam/utils_net.py +24 -0
- adam/utils_repl/__init__.py +0 -0
- adam/utils_repl/automata_completer.py +48 -0
- adam/utils_repl/repl_completer.py +46 -0
- adam/utils_repl/state_machine.py +173 -0
- adam/utils_sqlite.py +109 -0
- adam/version.py +5 -0
- {kaqing-1.77.0.dist-info → kaqing-2.0.171.dist-info}/METADATA +1 -1
- kaqing-2.0.171.dist-info/RECORD +236 -0
- kaqing-2.0.171.dist-info/entry_points.txt +3 -0
- kaqing-2.0.171.dist-info/top_level.txt +1 -0
- kaqing-1.77.0.dist-info/RECORD +0 -159
- kaqing-1.77.0.dist-info/entry_points.txt +0 -3
- kaqing-1.77.0.dist-info/top_level.txt +0 -1
- walker/__init__.py +0 -3
- walker/app_session.py +0 -168
- walker/checks/check_utils.py +0 -97
- walker/columns/columns.py +0 -43
- walker/commands/add_user.py +0 -68
- walker/commands/app.py +0 -67
- walker/commands/bash.py +0 -87
- walker/commands/cd.py +0 -115
- walker/commands/check.py +0 -68
- walker/commands/command.py +0 -104
- walker/commands/cp.py +0 -95
- walker/commands/cql_utils.py +0 -53
- walker/commands/devices.py +0 -89
- walker/commands/frontend/code_stop.py +0 -57
- walker/commands/frontend/setup.py +0 -60
- walker/commands/frontend/setup_frontend.py +0 -58
- walker/commands/frontend/teardown.py +0 -61
- walker/commands/frontend/teardown_frontend.py +0 -42
- walker/commands/issues.py +0 -69
- walker/commands/login.py +0 -72
- walker/commands/ls.py +0 -145
- walker/commands/medusa/medusa.py +0 -69
- walker/commands/medusa/medusa_backup.py +0 -61
- walker/commands/medusa/medusa_restore.py +0 -86
- walker/commands/medusa/medusa_show_backupjobs.py +0 -52
- walker/commands/medusa/medusa_show_restorejobs.py +0 -52
- walker/commands/param_set.py +0 -44
- walker/commands/postgres/postgres.py +0 -113
- walker/commands/postgres/postgres_session.py +0 -225
- walker/commands/preview_table.py +0 -98
- walker/commands/processes.py +0 -53
- walker/commands/pwd.py +0 -64
- walker/commands/reaper/reaper.py +0 -78
- walker/commands/reaper/reaper_forward.py +0 -100
- walker/commands/reaper/reaper_run_abort.py +0 -65
- walker/commands/reaper/reaper_runs.py +0 -97
- walker/commands/reaper/reaper_runs_abort.py +0 -83
- walker/commands/reaper/reaper_schedule_activate.py +0 -64
- walker/commands/reaper/reaper_schedule_start.py +0 -64
- walker/commands/reaper/reaper_schedule_stop.py +0 -64
- walker/commands/reaper/reaper_session.py +0 -159
- walker/commands/repair/repair.py +0 -68
- walker/commands/repair/repair_run.py +0 -72
- walker/commands/repair/repair_scan.py +0 -79
- walker/commands/report.py +0 -57
- walker/commands/restart.py +0 -61
- walker/commands/show/show.py +0 -72
- walker/commands/show/show_app_actions.py +0 -53
- walker/commands/show/show_cassandra_status.py +0 -35
- walker/commands/show/show_commands.py +0 -58
- walker/commands/show/show_processes.py +0 -35
- walker/commands/show/show_repairs.py +0 -47
- walker/commands/status.py +0 -128
- walker/commands/storage.py +0 -52
- walker/commands/user_entry.py +0 -69
- walker/commands/watch.py +0 -85
- walker/embedded_params.py +0 -2
- walker/k8s_utils/cassandra_clusters.py +0 -48
- walker/k8s_utils/cassandra_nodes.py +0 -26
- walker/k8s_utils/pods.py +0 -211
- walker/repl.py +0 -165
- walker/repl_commands.py +0 -58
- walker/repl_state.py +0 -211
- walker/sso/authn_ad.py +0 -94
- walker/sso/idp.py +0 -150
- walker/sso/idp_login.py +0 -29
- walker/sso/sso_config.py +0 -45
- walker/utils.py +0 -194
- walker/version.py +0 -5
- {walker → adam}/checks/__init__.py +0 -0
- {walker → adam}/checks/check_context.py +0 -0
- {walker → adam}/checks/issue.py +0 -0
- {walker → adam}/cli_group.py +0 -0
- {walker → adam}/columns/__init__.py +0 -0
- {walker/commands → adam/commands/audit}/__init__.py +0 -0
- {walker/commands/frontend → adam/commands/cql}/__init__.py +0 -0
- {walker/commands/medusa → adam/commands/deploy}/__init__.py +0 -0
- {walker/commands/postgres → adam/commands/devices}/__init__.py +0 -0
- {walker/commands/reaper → adam/commands/export}/__init__.py +0 -0
- {walker/commands/repair → adam/commands/medusa}/__init__.py +0 -0
- {walker → adam}/commands/nodetool_commands.py +0 -0
- {walker/commands/show → adam/commands/postgres}/__init__.py +0 -0
- {walker/k8s_utils → adam/commands/reaper}/__init__.py +0 -0
- {walker/sso → adam/commands/repair}/__init__.py +0 -0
- /walker/medusa_show_restorejobs.py → /adam/commands/show/__init__.py +0 -0
- {walker → adam}/repl_session.py +0 -0
- {kaqing-1.77.0.dist-info → kaqing-2.0.171.dist-info}/WHEEL +0 -0
walker/utils.py
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
from contextlib import redirect_stdout
|
|
2
|
-
import copy
|
|
3
|
-
import csv
|
|
4
|
-
import io
|
|
5
|
-
import random
|
|
6
|
-
import string
|
|
7
|
-
from dateutil import parser
|
|
8
|
-
import subprocess
|
|
9
|
-
import sys
|
|
10
|
-
import time
|
|
11
|
-
import click
|
|
12
|
-
|
|
13
|
-
def to_tabular(lines: str, header: str = None, dashed_line = False):
|
|
14
|
-
return lines_to_tabular(lines.split('\n'), header, dashed_line)
|
|
15
|
-
|
|
16
|
-
def lines_to_tabular(lines: list[str], header: str = None, dashed_line = False, separator = ' '):
|
|
17
|
-
maxes = []
|
|
18
|
-
nls = []
|
|
19
|
-
|
|
20
|
-
def format_line(line: str):
|
|
21
|
-
nl = []
|
|
22
|
-
words = line.split(separator)
|
|
23
|
-
for i, word in enumerate(words):
|
|
24
|
-
nl.append(word.ljust(maxes[i], ' '))
|
|
25
|
-
nls.append(' '.join(nl))
|
|
26
|
-
|
|
27
|
-
all_lines = lines
|
|
28
|
-
if header:
|
|
29
|
-
all_lines = [header] + lines
|
|
30
|
-
|
|
31
|
-
for line in all_lines:
|
|
32
|
-
words = line.split(separator)
|
|
33
|
-
for i, word in enumerate(words):
|
|
34
|
-
lw = len(word)
|
|
35
|
-
if len(maxes) <= i:
|
|
36
|
-
maxes.append(lw)
|
|
37
|
-
elif maxes[i] < lw:
|
|
38
|
-
maxes[i] = lw
|
|
39
|
-
|
|
40
|
-
if header:
|
|
41
|
-
format_line(header)
|
|
42
|
-
if dashed_line:
|
|
43
|
-
nls.append(''.ljust(sum(maxes) + (len(maxes) - 1) * 2, '-'))
|
|
44
|
-
for line in lines:
|
|
45
|
-
format_line(line)
|
|
46
|
-
|
|
47
|
-
return '\n'.join(nls)
|
|
48
|
-
|
|
49
|
-
def convert_seconds(total_seconds_float):
|
|
50
|
-
total_seconds_int = int(total_seconds_float) # Convert float to integer seconds
|
|
51
|
-
|
|
52
|
-
hours = total_seconds_int // 3600
|
|
53
|
-
remaining_seconds_after_hours = total_seconds_int % 3600
|
|
54
|
-
|
|
55
|
-
minutes = remaining_seconds_after_hours // 60
|
|
56
|
-
seconds = remaining_seconds_after_hours % 60
|
|
57
|
-
|
|
58
|
-
return hours, minutes, seconds
|
|
59
|
-
|
|
60
|
-
def epoch(timestamp_string: str):
|
|
61
|
-
return parser.parse(timestamp_string).timestamp()
|
|
62
|
-
|
|
63
|
-
def log(s = None):
|
|
64
|
-
# want to print out False or empty collection
|
|
65
|
-
if s == None:
|
|
66
|
-
print()
|
|
67
|
-
else:
|
|
68
|
-
click.echo(s)
|
|
69
|
-
|
|
70
|
-
def log2(s = None):
|
|
71
|
-
if s:
|
|
72
|
-
click.echo(s, err=True)
|
|
73
|
-
else:
|
|
74
|
-
print(file=sys.stderr)
|
|
75
|
-
|
|
76
|
-
def elapsed_time(start_time: float):
|
|
77
|
-
end_time = time.time()
|
|
78
|
-
elapsed_time = end_time - start_time
|
|
79
|
-
hours = int(elapsed_time // 3600)
|
|
80
|
-
minutes = int((elapsed_time % 3600) // 60)
|
|
81
|
-
seconds = int(elapsed_time % 60)
|
|
82
|
-
|
|
83
|
-
return f"{hours:02}:{minutes:02}:{seconds:02}"
|
|
84
|
-
|
|
85
|
-
def duration(start_time: float):
|
|
86
|
-
d = convert_seconds(time.time() - start_time)
|
|
87
|
-
t = []
|
|
88
|
-
if d[0]:
|
|
89
|
-
t.append(f'{d[0]}h')
|
|
90
|
-
if t or d[1]:
|
|
91
|
-
t.append(f'{d[1]}m')
|
|
92
|
-
t.append(f'{d[2]}s')
|
|
93
|
-
|
|
94
|
-
return ' '.join(t)
|
|
95
|
-
|
|
96
|
-
def strip(lines):
|
|
97
|
-
return '\n'.join([line.strip(' ') for line in lines.split('\n')]).strip('\n')
|
|
98
|
-
|
|
99
|
-
def deep_merge_dicts(dict1, dict2):
|
|
100
|
-
"""
|
|
101
|
-
Recursively merges dict2 into dict1.
|
|
102
|
-
If a key exists in both dictionaries and its value is a dictionary,
|
|
103
|
-
the function recursively merges those nested dictionaries.
|
|
104
|
-
Otherwise, values from dict2 overwrite values in dict1.
|
|
105
|
-
"""
|
|
106
|
-
merged_dict = dict1.copy() # Create a copy to avoid modifying original dict1
|
|
107
|
-
|
|
108
|
-
for key, value in dict2.items():
|
|
109
|
-
if key in merged_dict and isinstance(merged_dict[key], dict) and isinstance(value, dict):
|
|
110
|
-
# If both values are dictionaries, recursively merge them
|
|
111
|
-
merged_dict[key] = deep_merge_dicts(merged_dict[key], value)
|
|
112
|
-
elif key not in merged_dict or value:
|
|
113
|
-
# Otherwise, overwrite or add the value from dict2
|
|
114
|
-
merged_dict[key] = value
|
|
115
|
-
return merged_dict
|
|
116
|
-
|
|
117
|
-
def get_deep_keys(d, current_path=""):
|
|
118
|
-
"""
|
|
119
|
-
Recursively collects all combined keys (paths) from a deep dictionary.
|
|
120
|
-
|
|
121
|
-
Args:
|
|
122
|
-
d (dict): The dictionary to traverse.
|
|
123
|
-
current_path (str): The current path of keys, used for recursion.
|
|
124
|
-
|
|
125
|
-
Returns:
|
|
126
|
-
list: A list of strings, where each string represents a combined key path
|
|
127
|
-
(e.g., "key1.subkey1.nestedkey").
|
|
128
|
-
"""
|
|
129
|
-
keys = []
|
|
130
|
-
for k, v in d.items():
|
|
131
|
-
new_path = f"{current_path}.{k}" if current_path else str(k)
|
|
132
|
-
if isinstance(v, dict):
|
|
133
|
-
keys.extend(get_deep_keys(v, new_path))
|
|
134
|
-
else:
|
|
135
|
-
keys.append(new_path)
|
|
136
|
-
return keys
|
|
137
|
-
|
|
138
|
-
def display_help(replace_arg = False):
|
|
139
|
-
args = copy.copy(sys.argv)
|
|
140
|
-
if replace_arg:
|
|
141
|
-
args[len(args) - 1] = '--help'
|
|
142
|
-
else:
|
|
143
|
-
args.extend(['--help'])
|
|
144
|
-
subprocess.run(args)
|
|
145
|
-
|
|
146
|
-
def random_alphanumeric(length):
|
|
147
|
-
"""
|
|
148
|
-
Generates a random alphanumeric string of a specified length.
|
|
149
|
-
|
|
150
|
-
Args:
|
|
151
|
-
length (int): The desired length of the alphanumeric string.
|
|
152
|
-
|
|
153
|
-
Returns:
|
|
154
|
-
str: A randomly generated alphanumeric string.
|
|
155
|
-
"""
|
|
156
|
-
characters = string.ascii_letters + string.digits
|
|
157
|
-
random_string = ''.join(random.choice(characters) for _ in range(length))
|
|
158
|
-
|
|
159
|
-
return random_string.lower()
|
|
160
|
-
|
|
161
|
-
def json_to_csv(json_data: list[dict[any, any]], delimiter: str = ','):
|
|
162
|
-
def flatten_json(y):
|
|
163
|
-
out = {}
|
|
164
|
-
def flatten(x, name=''):
|
|
165
|
-
if type(x) is dict:
|
|
166
|
-
for a in x:
|
|
167
|
-
flatten(x[a], name + a + '_')
|
|
168
|
-
elif type(x) is list:
|
|
169
|
-
i = 0
|
|
170
|
-
for a in x:
|
|
171
|
-
flatten(a, name + str(i) + '_')
|
|
172
|
-
i += 1
|
|
173
|
-
else:
|
|
174
|
-
out[name[:-1]] = x
|
|
175
|
-
flatten(y)
|
|
176
|
-
return out
|
|
177
|
-
|
|
178
|
-
if isinstance(json_data, dict):
|
|
179
|
-
json_data = [json_data]
|
|
180
|
-
|
|
181
|
-
flattened_data = [flatten_json(record) for record in json_data]
|
|
182
|
-
if flattened_data:
|
|
183
|
-
keys = flattened_data[0].keys()
|
|
184
|
-
header = io.StringIO()
|
|
185
|
-
with redirect_stdout(header) as f:
|
|
186
|
-
dict_writer = csv.DictWriter(f, keys, delimiter=delimiter)
|
|
187
|
-
dict_writer.writeheader()
|
|
188
|
-
body = io.StringIO()
|
|
189
|
-
with redirect_stdout(body) as f:
|
|
190
|
-
dict_writer = csv.DictWriter(f, keys, delimiter=delimiter)
|
|
191
|
-
dict_writer.writerows(flattened_data)
|
|
192
|
-
return header.getvalue().strip('\r\n'), [l.strip('\r') for l in body.getvalue().split('\n')]
|
|
193
|
-
else:
|
|
194
|
-
return None
|
walker/version.py
DELETED
|
File without changes
|
|
File without changes
|
{walker → adam}/checks/issue.py
RENAMED
|
File without changes
|
{walker → adam}/cli_group.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{walker → adam}/repl_session.py
RENAMED
|
File without changes
|
|
File without changes
|