Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nise/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .helpers import gcp_calculate_persistent_disk_usage_amount
from .helpers import gcp_calculate_usage_amount_in_pricing

__version__ = "5.3.2"
__version__ = "5.3.3"
VERSION = __version__.split(".")
5 changes: 3 additions & 2 deletions nise/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ def _generate_azure_account_info(static_report_data=None):
"""Return Azure subscription, billing, and usage account info."""
fake = Faker()
company_name = fake.company()
company_name_sanitized = company_name.replace(" ", "_").replace(",", "")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For sanitizing the company name, you can use str.translate() which can be more efficient and concise when dealing with multiple character replacements or deletions. It performs all transformations in a single pass over the string.

Suggested change
company_name_sanitized = company_name.replace(" ", "_").replace(",", "")
company_name_sanitized = company_name.translate(str.maketrans(" ", "_", ","))

company_email = company_name.replace(" ", "").replace(",", "")
email_suffix = f"@{company_email}.com"

Expand All @@ -431,7 +432,7 @@ def _generate_azure_account_info(static_report_data=None):
subscription_guid = static_report_data.get("payer")
usage_accounts = tuple(static_report_data.get("user"))
currency_code = static_report_data.get("currency_code", "USD")
subscription_name = static_report_data.get("subscription_name", f"{company_name} Azure Subscription")
subscription_name = static_report_data.get("subscription_name", f"{company_name_sanitized}_Azure_Subscription")
for _ in usage_accounts:
account_name = fake.city()
trimmed_account_name = account_name.replace(" ", "")
Expand All @@ -447,7 +448,7 @@ def _generate_azure_account_info(static_report_data=None):
fake.ean(length=13),
)
currency_code = "USD"
subscription_name = f"{company_name} Azure Subscription"
subscription_name = f"{company_name_sanitized}_Azure_Subscription"
for _ in usage_accounts:
account_name = fake.city()
trimmed_account_name = account_name.replace(" ", "")
Expand Down