Skip to content

Commit 6f7a138

Browse files
authored
Move 'blurb populate' to blurb._populate (#56)
1 parent a4f867f commit 6f7a138

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

src/blurb/_populate.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
3+
from blurb._cli import subcommand
4+
from blurb._git import git_add_files, flush_git_add_files
5+
from blurb._template import sanitize_section, sections
6+
7+
8+
@subcommand
9+
def populate() -> None:
10+
"""Creates and populates the Misc/NEWS.d directory tree."""
11+
os.chdir('Misc')
12+
os.makedirs('NEWS.d/next', exist_ok=True)
13+
14+
for section in sections:
15+
dir_name = sanitize_section(section)
16+
dir_path = f'NEWS.d/next/{dir_name}'
17+
os.makedirs(dir_path, exist_ok=True)
18+
readme_path = f'NEWS.d/next/{dir_name}/README.rst'
19+
with open(readme_path, 'w', encoding='utf-8') as readme:
20+
readme.write(f'Put news entry ``blurb`` files for the *{section}* section in this directory.\n')
21+
git_add_files.append(dir_path)
22+
git_add_files.append(readme_path)
23+
flush_git_add_files()

src/blurb/blurb.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -474,26 +474,6 @@ def error(*a):
474474
sys.exit("Error: " + s)
475475

476476

477-
@subcommand
478-
def populate():
479-
"""
480-
Creates and populates the Misc/NEWS.d directory tree.
481-
"""
482-
os.chdir("Misc")
483-
os.makedirs("NEWS.d/next", exist_ok=True)
484-
485-
for section in sections:
486-
dir_name = sanitize_section(section)
487-
dir_path = f"NEWS.d/next/{dir_name}"
488-
os.makedirs(dir_path, exist_ok=True)
489-
readme_path = f"NEWS.d/next/{dir_name}/README.rst"
490-
with open(readme_path, "wt", encoding="utf-8") as readme:
491-
readme.write(f"Put news entry ``blurb`` files for the *{section}* section in this directory.\n")
492-
git_add_files.append(dir_path)
493-
git_add_files.append(readme_path)
494-
flush_git_add_files()
495-
496-
497477
@subcommand
498478
def export():
499479
"""

0 commit comments

Comments
 (0)