diff --git a/labm8/py/bazelutil.py b/labm8/py/bazelutil.py index f839dd05d..581207cd2 100644 --- a/labm8/py/bazelutil.py +++ b/labm8/py/bazelutil.py @@ -251,15 +251,14 @@ def GetDependentFiles( targets = stdout.rstrip().split("\n") # Now get the transitive dependencies of each target. - targets = [target for target in targets if target not in excluded_targets] - all_targets = targets.copy() - for i, target in enumerate(targets): - app.Log( - 1, - "Collecting transitive deps for target %d of %d: %s", - i + 1, - len(targets), - target, + targets = sorted( + [target for target in targets if target not in excluded_targets] + ) + all_targets = set(targets) + for i, target in enumerate(targets, start=1): + print( + f"\r\033[KCollecting transitive dependencies ({len(all_targets)}): {target}", + end="", ) bazel = self.BazelQuery([f"deps({target})"], stdout=subprocess.PIPE) grep = subprocess.Popen( @@ -276,11 +275,14 @@ def GetDependentFiles( raise OSError("grep of bazel query output failed") deps = stdout.rstrip().split("\n") - all_targets += [ - target for target in deps if target not in excluded_targets - ] - - paths = [self.MaybeTargetToPath(target) for target in all_targets] + all_targets = all_targets.union(set(deps)) + + print(f"\r\033[KCollected {len(all_targets)} transitive deps") + paths = [ + self.MaybeTargetToPath(target) + for target in all_targets + if not target in excluded_targets + ] return [path for path in paths if path] def GetBuildFiles(self, target: str) -> typing.List[pathlib.Path]: diff --git a/labm8/py/fs.py b/labm8/py/fs.py index de70230d7..320acaeee 100644 --- a/labm8/py/fs.py +++ b/labm8/py/fs.py @@ -465,8 +465,8 @@ def read(*components, **kwargs): # Multiple definitions to handle all cases. if ignore_comments: - comment_line_re = re.compile("^\s*{char}".format(char=comment_char)) - not_comment_re = re.compile("[^{char}]+".format(char=comment_char)) + comment_line_re = re.compile(r"^\s*{char}".format(char=comment_char)) + not_comment_re = re.compile(r"[^{char}]+".format(char=comment_char)) if rstrip: # Ignore comments, and right strip results. diff --git a/labm8/py/labtypes.py b/labm8/py/labtypes.py index 4c2d13385..9977bd7d2 100644 --- a/labm8/py/labtypes.py +++ b/labm8/py/labtypes.py @@ -17,7 +17,7 @@ import itertools import sys import typing -from collections import Mapping +from collections.abc import Mapping from six import string_types