Skip to content

Commit d812d68

Browse files
committed
Allow no new manfests or build history lines files if special flag is present during update_wiki
1 parent af0493a commit d812d68

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

tagging/update_wiki.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,14 @@ def remove_old_manifests(wiki_dir: Path) -> None:
118118
LOGGER.info(f"Removed manifest: {file.relative_to(wiki_dir)}")
119119

120120

121-
def update_wiki(wiki_dir: Path, hist_lines_dir: Path, manifests_dir: Path) -> None:
121+
def update_wiki(
122+
wiki_dir: Path, hist_lines_dir: Path, manifests_dir: Path, allow_no_files: bool
123+
) -> None:
122124
LOGGER.info("Updating wiki")
123125

124126
manifest_files = list(manifests_dir.rglob("*.md"))
125-
assert manifest_files, "expected to have some manifest files"
127+
if not allow_no_files:
128+
assert manifest_files, "expected to have some manifest files"
126129
for manifest_file in manifest_files:
127130
year_month = get_manifest_year_month(manifest_file)
128131
year = year_month[:4]
@@ -132,7 +135,10 @@ def update_wiki(wiki_dir: Path, hist_lines_dir: Path, manifests_dir: Path) -> No
132135
LOGGER.info(f"Added manifest file: {copy_to.relative_to(wiki_dir)}")
133136

134137
build_history_line_files = sorted(hist_lines_dir.rglob("*.txt"))
135-
assert build_history_line_files, "expected to have some build history line files"
138+
if not allow_no_files:
139+
assert (
140+
build_history_line_files
141+
), "expected to have some build history line files"
136142
for build_history_line_file in build_history_line_files:
137143
build_history_line = build_history_line_file.read_text()
138144
assert build_history_line.startswith("| `")
@@ -165,6 +171,13 @@ def update_wiki(wiki_dir: Path, hist_lines_dir: Path, manifests_dir: Path) -> No
165171
type=Path,
166172
help="Directory with manifest files",
167173
)
174+
arg_parser.add_argument(
175+
"--allow-no-files",
176+
action="store_true",
177+
help="Allow no manifest or history line files",
178+
)
168179
args = arg_parser.parse_args()
169180

170-
update_wiki(args.wiki_dir, args.hist_lines_dir, args.manifests_dir)
181+
update_wiki(
182+
args.wiki_dir, args.hist_lines_dir, args.manifests_dir, args.allow_no_files
183+
)

0 commit comments

Comments
 (0)