Skip to content

Commit

Permalink
Pattern match artefacts when more than one result
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
samuel-emrys committed Jun 3, 2021
1 parent 40d6ff3 commit 3c9dcbc
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions sphinx_multiversion/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,19 +428,26 @@ def main(argv=None):
# example.pdf in the target build directory
candidate_files = glob.glob(
"{build_dir}/**/*.{extension}".format(
build_dir=target_build_dir, extension=download_format,
build_dir=target_build_dir,
extension=download_format,
),
recursive=True,
)
build_file_pattern = "{project}.{extension}".format(
project=config.project.replace(" ", ""),
extension=download_format,
)
build_artefacts = [
x
for x in candidate_files
if pathlib.Path(x.lower()).name == build_file_pattern.lower()
]
if len(candidate_files) > 1:
build_file_pattern = (
"{project}.{extension}".format(
project=config.project.replace(" ", ""),
extension=download_format,
)
)
build_artefacts = [
x
for x in candidate_files
if pathlib.Path(x.lower()).name
== build_file_pattern.lower()
]
else:
build_artefacts = candidate_files
if len(build_artefacts) == 0:
logger.warning(
(
Expand Down

0 comments on commit 3c9dcbc

Please sign in to comment.