|
58 | 58 | import time |
59 | 59 |
|
60 | 60 | from blurb._cli import main, subcommand |
61 | | - |
62 | | - |
63 | | -# |
64 | | -# This template is the canonical list of acceptable section names! |
65 | | -# It's parsed internally into the "sections" set. |
66 | | -# |
67 | | - |
68 | | -template = """ |
69 | | -
|
70 | | -# |
71 | | -# Please enter the relevant GitHub issue number here: |
72 | | -# |
73 | | -.. gh-issue: |
74 | | -
|
75 | | -# |
76 | | -# Uncomment one of these "section:" lines to specify which section |
77 | | -# this entry should go in in Misc/NEWS.d. |
78 | | -# |
79 | | -#.. section: Security |
80 | | -#.. section: Core and Builtins |
81 | | -#.. section: Library |
82 | | -#.. section: Documentation |
83 | | -#.. section: Tests |
84 | | -#.. section: Build |
85 | | -#.. section: Windows |
86 | | -#.. section: macOS |
87 | | -#.. section: IDLE |
88 | | -#.. section: Tools/Demos |
89 | | -#.. section: C API |
90 | | -
|
91 | | -# Write your Misc/NEWS.d entry below. It should be a simple ReST paragraph. |
92 | | -# Don't start with "- Issue #<n>: " or "- gh-issue-<n>: " or that sort of stuff. |
93 | | -########################################################################### |
94 | | -
|
95 | | -
|
96 | | -""".lstrip() |
| 61 | +from blurb._template import ( |
| 62 | + next_filename_unsanitize_sections, sanitize_section, |
| 63 | + sanitize_section_legacy, sections, template, unsanitize_section, |
| 64 | +) |
97 | 65 |
|
98 | 66 | root = None # Set by chdir_to_repo_root() |
99 | 67 | original_dir = None |
100 | | -sections = [] |
101 | | - |
102 | | -for line in template.split('\n'): |
103 | | - line = line.strip() |
104 | | - prefix, found, section = line.partition("#.. section: ") |
105 | | - if found and not prefix: |
106 | | - sections.append(section.strip()) |
107 | | - |
108 | | - |
109 | | -_sanitize_section = { |
110 | | - "C API": "C_API", |
111 | | - "Core and Builtins": "Core_and_Builtins", |
112 | | - "Tools/Demos": "Tools-Demos", |
113 | | - } |
114 | | - |
115 | | - |
116 | | -def sanitize_section(section): |
117 | | - """ |
118 | | - Clean up a section string, making it viable as a directory name. |
119 | | - """ |
120 | | - return _sanitize_section.get(section, section) |
121 | | - |
122 | | - |
123 | | -def sanitize_section_legacy(section): |
124 | | - """ |
125 | | - Clean up a section string, making it viable as a directory name (allow spaces). |
126 | | - """ |
127 | | - return section.replace("/", "-") |
128 | | - |
129 | | - |
130 | | -_unsanitize_section = { |
131 | | - "C_API": "C API", |
132 | | - "Core_and_Builtins": "Core and Builtins", |
133 | | - "Tools-Demos": "Tools/Demos", |
134 | | - } |
135 | | - |
136 | | - |
137 | | -def unsanitize_section(section): |
138 | | - return _unsanitize_section.get(section, section) |
139 | | - |
140 | | -def next_filename_unsanitize_sections(filename): |
141 | | - for key, value in _unsanitize_section.items(): |
142 | | - for separator in "/\\": |
143 | | - key = f"{separator}{key}{separator}" |
144 | | - value = f"{separator}{value}{separator}" |
145 | | - filename = filename.replace(key, value) |
146 | | - return filename |
147 | 68 |
|
148 | 69 |
|
149 | 70 | def textwrap_body(body, *, subsequent_indent=''): |
|
0 commit comments