From 2f8d64f11f06eb4f2e6f7240cb358449d8c71352 Mon Sep 17 00:00:00 2001 From: Tejasvi <51499946+tejasvi541@users.noreply.github.com> Date: Tue, 15 Oct 2024 08:11:07 -0400 Subject: [PATCH] style: Convert camelCase to snake_case (#190) * Requested Changes - Changed some variable names to snake case - Removed unused imports from cli.py - Added Some dev dependencies like autopep8 and pylint for effective searches will remove before final commit - Added a custom py file to filter pylint logs, will remove before final commit * removed filter script and logs, and changed names where's its needed * Add installation instruction to README.md Fix: corrected the file name __init__.py Signed-off-by: pravo23 Enhance GitHub Actions Workflow with PR Triggers (#148) * Add PR triggers to github actions workflow * Update lint.yml Centralized version definition to simplify version management (#142) Co-authored-by: Rafid Aslam Update build_test.yml (#149) * Update build_test.yml * Update lint.yml Update logger initialization to use module-specific loggers #140 Changed "logger = logging.getLogger()" line of code to "logger = logging.getLogger(__name__)" in all files Removed the TODO Comments - "# TODO: At least add __name__ as the name for the logger" in all files https://github.com/StackGuardian/tirith/issues/140 Removed RESULTS text from error Resolved - Generalize the function get_path_value_from_dict Refactor get_path_value_from_dict Moved get_path_value_from_dict to common.py. Refactored Kubernetes and JSON handler files to import from common.py. Updated Common.py Fix linting (#167) Add a getting started guide in README.md (#139) * Add a getting started guide in README.md * Add description of getting started activity, and some minor fixes Add maintainers in README and CODEOWNERS file Add additional rules and guidelines to contributing.md Add examples for commit messages and guidelines for solving issues Update CONTRIBUTING.md with guidelines about solving issues Add separate heading about solving issues, and add examples for writing descriptions in commit changes setup the docs base (#177) * created the template for the official documentation * setting up the environment * cleaned up the documentation setup * adjusted the color scheme * setup the basic pages for the tirith documentation * updated the intro page Add dev container Add dev container Closes https://github.com/StackGuardian/tirith/issues/175 Update Readme.MD Simplify type checking in sort_collections() Closes https://github.com/StackGuardian/tirith/issues/185 Add Variable Replacement Support in Tirith Policies (#171) * Add support for parameterizing Tirith policies * Use pydash.get() and check for match only if the value is of type str * Add variable replacement for meta and eval_expression in a policy * Add unit tests for policy parameterization, change return type for cases where the path was not found, and change syntax of entering the variable names * Fix linting * tirith parametrization --------- Co-authored-by: Rafid Aslam Removed RESULTS text from error Resolved - Generalize the function get_path_value_from_dict Refactor get_path_value_from_dict Moved get_path_value_from_dict to common.py. Refactored Kubernetes and JSON handler files to import from common.py. Updated Common.py Fix linting (#167) Add a getting started guide in README.md (#139) * Add a getting started guide in README.md * Add description of getting started activity, and some minor fixes Add maintainers in README and CODEOWNERS file Add additional rules and guidelines to contributing.md Add examples for commit messages and guidelines for solving issues Update CONTRIBUTING.md with guidelines about solving issues Add separate heading about solving issues, and add examples for writing descriptions in commit changes Merge branch 'main' of https://github.com/StackGuardian/tirith --- setup.py | 4 ++-- src/tirith/cli.py | 1 - src/tirith/providers/infracost/handler.py | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/setup.py b/setup.py index b80589c..1a6cf4f 100644 --- a/setup.py +++ b/setup.py @@ -16,8 +16,8 @@ def read(*names, **kwargs): - with io.open(join(dirname(__file__), *names), encoding=kwargs.get("encoding", "utf8")) as fh: - return fh.read() + with io.open(join(dirname(__file__), *names), encoding=kwargs.get("encoding", "utf8")) as file_handle: + return file_handle.read() setup( diff --git a/src/tirith/cli.py b/src/tirith/cli.py index 8e83da8..6642e31 100755 --- a/src/tirith/cli.py +++ b/src/tirith/cli.py @@ -8,7 +8,6 @@ import sys import textwrap -import tirith.providers.terraform_plan.handler as python_tf_plan_handler from tirith.logging import setup_logging from tirith.prettyprinter import pretty_print_result_dict from tirith.status import ExitStatus diff --git a/src/tirith/providers/infracost/handler.py b/src/tirith/providers/infracost/handler.py index dd6c84e..956cc5f 100644 --- a/src/tirith/providers/infracost/handler.py +++ b/src/tirith/providers/infracost/handler.py @@ -9,7 +9,7 @@ def __get_all_costs(operation_type, input_data): "total_monthly_cost": ["totalMonthlyCost", "monthlyCost"], "total_hourly_cost": ["totalHourlyCost", "hourlyCost"], } - totalSum = 0 + total_sum = 0 if "projects" in input_data: for project in input_data["projects"]: if "breakdown" in project and "resources" in project["breakdown"]: @@ -19,19 +19,19 @@ def __get_all_costs(operation_type, input_data): and resource[pointer[operation_type][0]] and resource[pointer[operation_type][0]] != "null" ): - totalSum += float(resource[pointer[operation_type][0]]) + total_sum += float(resource[pointer[operation_type][0]]) elif ( pointer[operation_type][1] in resource and resource[pointer[operation_type][1]] and resource[pointer[operation_type][1]] != "null" ): # Support new schema for Infracost - totalSum += float(resource[pointer[operation_type][1]]) + total_sum += float(resource[pointer[operation_type][1]]) else: pass # raise KeyError(f'{costType} not found in one of the resource') - logger.debug(f"Total sum of {operation_type} of all resources : {totalSum}") - return totalSum + logger.debug(f"Total sum of {operation_type} of all resources : {total_sum}") + return total_sum else: raise KeyError("breakdown/resources not found in one of the project") else: @@ -45,7 +45,7 @@ def __get_resources_costs(resource_type, operation_type, input_data): "total_monthly_cost": ["totalMonthlyCost", "monthlyCost"], "total_hourly_cost": ["totalHourlyCost", "hourlyCost"], } - totalSum = 0 + total_sum = 0 if "projects" in input_data: for project in input_data["projects"]: if "breakdown" in project and "resources" in project["breakdown"]: @@ -57,7 +57,7 @@ def __get_resources_costs(resource_type, operation_type, input_data): and resource[pointer[operation_type][0]] and resource[pointer[operation_type][0]] != "null" ): - totalSum += float(resource[pointer[operation_type][0]]) + total_sum += float(resource[pointer[operation_type][0]]) elif ( pointer[operation_type][1] in resource and "name" in resource @@ -65,12 +65,12 @@ def __get_resources_costs(resource_type, operation_type, input_data): and resource[pointer[operation_type][1]] and resource[pointer[operation_type][1]] != "null" ): - totalSum += float(resource[pointer[operation_type][1]]) + total_sum += float(resource[pointer[operation_type][1]]) else: pass # raise KeyError(f'{costType} not found in one of the resource') - logger.debug(f"Total sum of {operation_type} of specific resources : {totalSum}") - return totalSum + logger.debug(f"Total sum of {operation_type} of specific resources : {total_sum}") + return total_sum else: raise KeyError("breakdown/resources not found in one of the project") else: