Skip to content

Commit

Permalink
Merge pull request #26 from biosafetylvl5/19-change-description-field…
Browse files Browse the repository at this point in the history
…-in-template-to-a-pipe-rather-than-single-quotes-to-support-multi-line-descriptions-by-default

Make the description field a pipe by default
  • Loading branch information
biosafetylvl5 authored Sep 24, 2024
2 parents 63d074a + da86817 commit 9ebc50e
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions src/brassy/brassy.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,41 @@ def get_yaml_template_path(file_path_arg, working_dir=os.getcwd()):

def create_blank_template_yaml_file(file_path_arg, console, working_dir="."):
"""
Create a blank YAML file with default categories.
Creates a blank YAML template file with a predefined structure.
This function generates a YAML file at the specified path with a default
template. It handles special characters required for YAML compatibility and writes
the file to disk.
Parameters
----------
file_path : str
Path to the output YAML file.
file_path_arg : str
The file path of the YAML template as passed via the CLI.
console : rich.console.Console
A Rich Console object used for displaying messages and errors to the user.
working_dir : str, optional
The working directory path. Defaults to the current directory ".".
Raises
------
SystemExit
If a Git repo is not found in the current working directory and no file path
is provided, the program exits with an error message.
Notes
-----
This function performs a string replacement to insert a "|" due to an issue with
YAML's handling of pipe symbols. For more details, see:
https://github.com/yaml/pyyaml/pull/822
"""
pipe_replace_string = "REPLACE_ME_WITH_PIPE"
default_yaml = {
category: [
{
"title": "",
"description": "",
"description": pipe_replace_string,
"files": {change: [""] for change in Settings.valid_changes},
"related-issue": {"number": "null", "repo_url": ""},
"related-issue": {"number": None, "repo_url": ""},
# in time, extract from the first and last commit
"date": {"start": None, "finish": None},
}
Expand All @@ -238,7 +259,11 @@ def create_blank_template_yaml_file(file_path_arg, console, working_dir="."):
)
exit(1)
with open(yaml_template_path, "w") as file:
yaml.dump(default_yaml, file, sort_keys=False, default_flow_style=False)
yaml_text = yaml.safe_dump(
default_yaml, sort_keys=False, default_flow_style=False
)
yaml_text = yaml_text.replace(pipe_replace_string, "|")
file.write(yaml_text)


def get_git_status(repo_path="."):
Expand Down

0 comments on commit 9ebc50e

Please sign in to comment.