Refactor the HWA Jira issues CSV generator script#2
Merged
glaubergedoz merged 1 commit intomainfrom Dec 2, 2025
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor: HelloWorldAtlas Jira Issues CSV Generator
Overview
This change refactors the Python script used to generate Jira issues from a CSV file containing the applications in the HelloWorldAtlas product line from GedozTech Lab.
The goal is to keep the script simple and focused on its original purpose, while aligning it with modern Python best practices and making it easier to maintain, understand, and evolve.
Goals
Key Changes
1. Structure and CLI
Introduced
argparsefor command-line parsing instead of manually usingsys.argv:--helpsupport with usage documentation.Extracted logic into dedicated functions:
split_multi()— parses semicolon-separated multi-value fields.read_source_rows()— loads the input CSV into memory.compute_max_multi_counts()— determines the maximum number ofStackandLabelvalues across all rows.build_header()— builds the CSV header dynamically based on the computed counts.build_base_row()— constructs the fixed part of each issue row.generate_issue_rows_for_application()— generates all issues for a single application.This separation makes the script much easier to follow and test in isolation.
2. Readability and Maintainability
Introduced constants for input column names:
This helps avoid typos and centralizes any future schema changes in a single place.
Replaced repeated issue blocks with a data-driven structure:
Previously, each of the five issues per application was implemented as a separate block of code, repeating the same boilerplate for building rows.
The refactored version uses a simple list of issue definitions:
Each entry holds
(issue_type, summary_template, description, components), and the script loops over this list to generate the rows. The{app}placeholder is filled dynamically for each application. This approach reduces duplication and makes it easy to add, remove, or modify issues in the future.Centralized the construction of the base issue row:
The
build_base_row()helper builds the fixed part of a row (fields that do not depend on the specific issue type except forissue_type,summary,description, andcomponents):This keeps the logic consistent across all issues.
3. PEP 8, Type Hints, and Style
Added type hints throughout the script:
split_multi(value: str | None) -> List[str],read_source_rows(input_path: Path) -> List[Dict[str, str]], etc.Improved code formatting and line-wrapping:
Imports are kept minimal and standard-library only (
argparse,csv,sys,pathlib,typing,collections.abc).4. Robustness and Error Handling
Added explicit error handling for file operations:
Graceful handling of empty input:
5. Jira-Specific Behavior (Stack and Label Columns)
Preserved the multi-value behavior for Jira fields:
The output header defines multiple columns with the exact same name
"Stack"and"Label":This is intentional: Jira treats repeated column names as multiple values for the same field, consolidating them into the
StackandLabelsfields of the issue.Comments were added in the code to document this behavior and avoid confusion for future readers.
Multi-value parsing remains robust:
The
split_multi()helper:Noneor empty strings.This ensures that values like
"; Go ; Python;; JS "are normalized to["Go", "Python", "JS"].6. How to Run
After the refactor, usage remains simple and explicit:
input.csv: the source spreadsheet with HelloWorldAtlas applications.output.csv: the generated Jira issues ready for import.Use
--helpto display usage information: