Skip to content

Commit

Permalink
Merge pull request #77 from ChrisCummins/feature/export_subtree
Browse files Browse the repository at this point in the history
Update subtree export
  • Loading branch information
ChrisCummins authored Jan 25, 2020
2 parents dbbd125 + 8d7f175 commit 3a19a92
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
30 changes: 16 additions & 14 deletions labm8/py/bazelutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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]:
Expand Down
4 changes: 2 additions & 2 deletions labm8/py/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion labm8/py/labtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import itertools
import sys
import typing
from collections import Mapping
from collections.abc import Mapping

from six import string_types

Expand Down

0 comments on commit 3a19a92

Please sign in to comment.