Skip to content

Commit

Permalink
Minor readability fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed Oct 9, 2023
1 parent ae2b41b commit 2165a49
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions scantags.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ def grep_file(filename: str, line_regex: re.Pattern) -> Iterator[tuple[str, int,
pass


def grep_files(
directory: str, filenames: list[str], line_regex: re.Pattern
) -> Iterator[tuple[str, int, str]]:
"""
Grep files
"""
for filename in filenames:
yield from grep_file(os.path.join(directory, filename), line_regex)


def grep_dir(
directory: str,
line_regex: re.Pattern,
Expand Down Expand Up @@ -150,12 +160,7 @@ def process_line(
futures = []
for file, line_number, tag in chain(
grep_dir(directory, LINE_REGEX, FILE_PATTERN, IGNORE_DIRECTORIES),
*map(
lambda f: grep_file(
os.path.join(directory, f), re.compile(f"({TAG_REGEX})")
),
INCLUDE_FILES,
),
grep_files(directory, INCLUDE_FILES, re.compile(f"({TAG_REGEX})")),
):
file = file.removeprefix(f"{directory}/")
futures.append(executor.submit(process_line, file, line_number, tag))
Expand Down
4 changes: 2 additions & 2 deletions services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def get_urltag(string: str) -> dict[str, str] | None:
issue_id = parse_qs(url.query)["id"][0]
elif not path.startswith("issues/") and "/issue" in path:
# Support Bitbucket optional description after issue number
if not os.path.basename(path).isdigit():
path = os.path.dirname(path)
if not re.search("/[0-9]+$", path):
path = path.rsplit("/", 1)[0]
# Gitlab stuff
path = path.replace("/-/", "/")
repo, _, issue_id = path.rsplit("/", 2)
Expand Down

0 comments on commit 2165a49

Please sign in to comment.