Skip to content

Commit

Permalink
refactor: use list comprehension rather filter+lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
sgaist authored and consideRatio committed Oct 31, 2022
1 parent 95b5ace commit 2e5e3c0
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions repo2docker/buildpacks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,16 +589,18 @@ def _filter_tar(tarinfo):

exclude = []

for ignore_file in [".dockerignore", ".containerignore"]:
if os.path.exists(ignore_file):
with open(ignore_file, "r") as f:
for ignore_file_name in [".dockerignore", ".containerignore"]:
if os.path.exists(ignore_file_name):
with open(ignore_file_name, "r") as ignore_file:
cleaned_lines = [
line.strip() for line in ignore_file.read().splitlines()
]
exclude.extend(
list(
filter(
lambda x: x != "" and x[0] != "#",
[l.strip() for l in f.read().splitlines()],
)
)
[
line
for line in cleaned_lines
if line != "" and line[0] != "#"
]
)

if not exclude:
Expand Down

0 comments on commit 2e5e3c0

Please sign in to comment.