Skip to content

Commit

Permalink
style: Convert camelCase to snake_case (#190)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

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 <[email protected]>
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
#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 #175

Update Readme.MD

Simplify type checking in sort_collections()

Closes #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 <[email protected]>
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
  • Loading branch information
tejasvi541 authored Oct 15, 2024
1 parent 0e9a0c2 commit 2f8d64f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion src/tirith/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions src/tirith/providers/infracost/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand All @@ -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:
Expand All @@ -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"]:
Expand All @@ -57,20 +57,20 @@ 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
and resource["name"].split(".")[0] in resource_type
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:
Expand Down

0 comments on commit 2f8d64f

Please sign in to comment.