Skip to content

Commit a8d3932

Browse files
committed
Simplify using findall.
1 parent bb05694 commit a8d3932

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

build_docs.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,19 +280,16 @@ def locate_nearest_version(available_versions, target_version):
280280
return tuple_to_version(found)
281281

282282

283-
def translation_branch(locale_repo, locale_clone_dir, needed_version):
283+
def translation_branch(locale_repo, locale_clone_dir, needed_version: str):
284284
"""Some cpython versions may be untranslated, being either too old or
285285
too new.
286286
287287
This function looks for remote branches on the given repo, and
288288
returns the name of the nearest existing branch.
289289
"""
290-
git_clone(locale_repo, locale_clone_dir)
290+
# git_clone(locale_repo, locale_clone_dir)
291291
remote_branches = run(["git", "-C", locale_clone_dir, "branch", "-r"]).stdout
292-
branches = []
293-
for branch in remote_branches.split("\n"):
294-
if re.match(r".*/[0-9]+\.[0-9]+$", branch):
295-
branches.append(branch.split("/")[-1])
292+
branches = re.findall(r"/([0-9]+\.[0-9]+)$", remote_branches, re.M)
296293
return locate_nearest_version(branches, needed_version)
297294

298295

0 commit comments

Comments
 (0)