Skip to content

Commit

Permalink
force lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Jan 16, 2026
1 parent 1d11503 commit 49333e6
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions local-app/python-tools/sso-tools/sso-create-sc-group.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env python

import argparse
import shutil
from pathlib import Path
from jinja2 import Environment, FileSystemLoader

# Version History:
# 1.0.0: Initial release
# 1.0.1: Added shebang, exposed variables to Jinja2, updated versioning
__version__ = "1.0.1"
# 1.0.1: Added shebang, exposed variables to Jinja2
# 1.0.2: Enforced lowercase for group and created_group names
__version__ = "1.0.2"

def create_sc_group():
parser = argparse.ArgumentParser(description="Automate file creation from templates.")
Expand All @@ -19,14 +19,15 @@ def create_sc_group():

args = parser.parse_args()

# 1. Determine the 'group' name (from arg or folder name)
group_name = args.group if args.group else Path.cwd().name
# 1. Determine the 'group' name and force to lowercase
raw_group = args.group if args.group else Path.cwd().name
group_name = raw_group.lower()

# 2. Define the 'created_group' string
# 2. Define the 'created_group' string and force to lowercase
if args.application_label:
created_group = f"{args.business_label}-{args.application_label}-{group_name}"
created_group = f"{args.business_label}-{args.application_label}-{group_name}".lower()
else:
created_group = f"{args.business_label}-{group_name}"
created_group = f"{args.business_label}-{group_name}".lower()

# 3. Setup paths
template_dir = Path("TEMPLATE")
Expand All @@ -41,7 +42,7 @@ def create_sc_group():
# 4. Initialize Jinja2 Environment
env = Environment(loader=FileSystemLoader(str(template_dir)))

# 5. Expose variables to Jinja2 templates
# 5. Expose variables to Jinja2 templates (all relevant strings are now lowercase)
render_vars = {
"business_label": args.business_label,
"application_label": args.application_label,
Expand All @@ -57,7 +58,8 @@ def create_sc_group():
continue # Skips subdirectories

if item.suffix == ".j2":
# Rule: Rename GROUP.extension.j2 to {created_group}.extension
# Rule: Replace 'GROUP' with created_group and strip '.j2'
# Note: We replace the literal string 'GROUP' in the filename
new_filename = item.name.replace("GROUP", created_group).replace(".j2", "")
target_path = target_dir / new_filename

Expand All @@ -77,3 +79,4 @@ def create_sc_group():

if __name__ == "__main__":
create_sc_group()

0 comments on commit 49333e6

Please sign in to comment.