From cbe44a8662a3df5e4b887beb19428f843a838336 Mon Sep 17 00:00:00 2001 From: cktricky Date: Fri, 21 Sep 2018 22:52:30 -0400 Subject: [PATCH] kewl printing now --- requirements.txt | 1 + weirdAAL.py | 29 +++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/requirements.txt b/requirements.txt index 3ae7987..dd47ee7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ python-dateutil==2.6.1 s3transfer==0.1.11 six==1.11.0 virtualenv==15.1.0 +tabulate=0.8.2 diff --git a/weirdAAL.py b/weirdAAL.py index b16bbd4..c79be88 100755 --- a/weirdAAL.py +++ b/weirdAAL.py @@ -14,6 +14,8 @@ from modules import * import sys import builtins import re +from tabulate import tabulate +import textwrap os.environ['AWS_SHARED_CREDENTIALS_FILE'] = '.env' @@ -97,13 +99,28 @@ def make_the_list(): and not (m == "modules.gcp")): make_list_of_methods("gcp", m) +def normalize_comments(string): + string = textwrap.fill(string.strip(), 40) + return string + + +def make_tabulate_rows(hash, cloud_provider): + entire_contents = [] + for (key) in hash: + for item in hash[key]: + for (k,v) in item.items(): + normalized_comment = normalize_comments(v) + entire_contents.append([cloud_provider, key, k, normalized_comment]) + + return entire_contents + + + def print_the_list(): - print("AWS") - print("---") - for (k) in aws_module_methods_info: - print(k) - print(aws_module_methods_info[k]) - print("....") + aws_rows = make_tabulate_rows(aws_module_methods_info, 'AWS') + gcp_rows = make_tabulate_rows(gcp_module_methods_info, 'GCP') + print(tabulate(aws_rows, headers=['Cloud Provider', 'Service', 'Mod', 'Desc'])) + print(tabulate(gcp_rows, headers=['Cloud Provider', 'Service', 'Mod', 'Desc'])) # Need to figure out if we have keys in the ENV or not try: