diff --git a/src/blurb/_populate.py b/src/blurb/_populate.py new file mode 100644 index 0000000..c1febc5 --- /dev/null +++ b/src/blurb/_populate.py @@ -0,0 +1,23 @@ +import os + +from blurb._cli import subcommand +from blurb._git import git_add_files, flush_git_add_files +from blurb._template import sanitize_section, sections + + +@subcommand +def populate() -> None: + """Creates and populates the Misc/NEWS.d directory tree.""" + os.chdir('Misc') + os.makedirs('NEWS.d/next', exist_ok=True) + + for section in sections: + dir_name = sanitize_section(section) + dir_path = f'NEWS.d/next/{dir_name}' + os.makedirs(dir_path, exist_ok=True) + readme_path = f'NEWS.d/next/{dir_name}/README.rst' + with open(readme_path, 'w', encoding='utf-8') as readme: + readme.write(f'Put news entry ``blurb`` files for the *{section}* section in this directory.\n') + git_add_files.append(dir_path) + git_add_files.append(readme_path) + flush_git_add_files() diff --git a/src/blurb/blurb.py b/src/blurb/blurb.py index 2fe2c5f..1b20077 100755 --- a/src/blurb/blurb.py +++ b/src/blurb/blurb.py @@ -474,26 +474,6 @@ def error(*a): sys.exit("Error: " + s) -@subcommand -def populate(): - """ -Creates and populates the Misc/NEWS.d directory tree. - """ - os.chdir("Misc") - os.makedirs("NEWS.d/next", exist_ok=True) - - for section in sections: - dir_name = sanitize_section(section) - dir_path = f"NEWS.d/next/{dir_name}" - os.makedirs(dir_path, exist_ok=True) - readme_path = f"NEWS.d/next/{dir_name}/README.rst" - with open(readme_path, "wt", encoding="utf-8") as readme: - readme.write(f"Put news entry ``blurb`` files for the *{section}* section in this directory.\n") - git_add_files.append(dir_path) - git_add_files.append(readme_path) - flush_git_add_files() - - @subcommand def export(): """