Skip to content

Commit 3c9dcbc

Browse files
committed
Pattern match artefacts when more than one result
Refactored pattern matching to only match patterns when there's more than one result. When there's one result, this is assumed to be the build artefact, which should provide some flexibility for artefact recognition without sacrificing quality. This also opens the door for future filtering based on user specified patterns.
1 parent 40d6ff3 commit 3c9dcbc

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

sphinx_multiversion/main.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -428,19 +428,26 @@ def main(argv=None):
428428
# example.pdf in the target build directory
429429
candidate_files = glob.glob(
430430
"{build_dir}/**/*.{extension}".format(
431-
build_dir=target_build_dir, extension=download_format,
431+
build_dir=target_build_dir,
432+
extension=download_format,
432433
),
433434
recursive=True,
434435
)
435-
build_file_pattern = "{project}.{extension}".format(
436-
project=config.project.replace(" ", ""),
437-
extension=download_format,
438-
)
439-
build_artefacts = [
440-
x
441-
for x in candidate_files
442-
if pathlib.Path(x.lower()).name == build_file_pattern.lower()
443-
]
436+
if len(candidate_files) > 1:
437+
build_file_pattern = (
438+
"{project}.{extension}".format(
439+
project=config.project.replace(" ", ""),
440+
extension=download_format,
441+
)
442+
)
443+
build_artefacts = [
444+
x
445+
for x in candidate_files
446+
if pathlib.Path(x.lower()).name
447+
== build_file_pattern.lower()
448+
]
449+
else:
450+
build_artefacts = candidate_files
444451
if len(build_artefacts) == 0:
445452
logger.warning(
446453
(

0 commit comments

Comments
 (0)