Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: packager.py

Issue 29490563: Issue 3967 - Properly handle non-existing file-mappings (Closed)
Patch Set: Created July 17, 2017, 12:27 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packager.py
diff --git a/packager.py b/packager.py
index 4c6be80fd7b235adf2a98b17182d9eb847b70fbe..c9176ab54e1508c2421f0eadccf64512b4b52039 100644
--- a/packager.py
+++ b/packager.py
@@ -91,19 +91,18 @@ class Files(dict):
dict.__setitem__(self, key, value)
def isIncluded(self, relpath):
+ return relpath.split('/')[0] in self.includedFiles
+
+ def is_ignored(self, relpath):
parts = relpath.split('/')
- if not parts[0] in self.includedFiles:
- return False
- for part in parts:
- if part in self.ignoredFiles:
- return False
- return True
+ return any([part in self.ignoredFiles for part in parts])
Sebastian Noack 2017/07/17 14:02:32 Nit: The brackets in order to generate a temporary
tlucas 2017/07/17 14:56:16 Acknowledged.
def read(self, path, relpath='', skip=()):
if os.path.isdir(path):
for file in os.listdir(path):
name = relpath + ('/' if relpath != '' else '') + file
- if name not in skip and self.isIncluded(name):
+ if (name not in skip
+ and self.isIncluded(name) and not self.is_ignored(name)):
self.read(os.path.join(path, file), name, skip)
else:
with open(path, 'rb') as file:
@@ -115,9 +114,9 @@ class Files(dict):
for item in mappings:
target, source = item
- # Make sure the file is inside an included directory
- if '/' in target and not self.isIncluded(target):
+ if '/' in target and self.is_ignored(target):
continue
+
parts = source.split('/')
path = os.path.join(os.path.dirname(item.source), *parts)
if os.path.exists(path):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld