Merge pull request #135 from jorix/3496-Build_force_exclude

Skip files that are listed in the exclude config list even if they are dependencies of other files.  Thanks @jorix for the enhancement.
This commit is contained in:
Tim Schaub
2012-01-17 12:39:04 -08:00
+18 -5
View File
@@ -53,12 +53,21 @@ class SourceFile:
Represents a Javascript source code file. Represents a Javascript source code file.
""" """
def __init__(self, filepath, source): def __init__(self, filepath, source, cfgExclude):
""" """
""" """
self.filepath = filepath self.filepath = filepath
self.source = source self.source = source
self.excludedFiles = []
self.requiredFiles = []
auxReq = re.findall(RE_REQUIRE, self.source)
for filename in auxReq:
if undesired(filename, cfgExclude):
self.excludedFiles.append(filename)
else:
self.requiredFiles.append(filename)
self.requiredBy = [] self.requiredBy = []
@@ -67,8 +76,7 @@ class SourceFile:
Extracts the dependencies specified in the source code and returns Extracts the dependencies specified in the source code and returns
a list of them. a list of them.
""" """
# TODO: Cache? return self.requiredFiles
return re.findall(RE_REQUIRE, self.source)
requires = property(fget=_getRequirements, doc="") requires = property(fget=_getRequirements, doc="")
@@ -176,7 +184,7 @@ def run (sourceDirectory, outputFilename = None, configFile = None,
print "Importing: %s" % filepath print "Importing: %s" % filepath
fullpath = os.path.join(sourceDirectory, filepath).strip() fullpath = os.path.join(sourceDirectory, filepath).strip()
content = open(fullpath, "U").read() # TODO: Ensure end of line @ EOF? content = open(fullpath, "U").read() # TODO: Ensure end of line @ EOF?
files[filepath] = SourceFile(filepath, content) # TODO: Chop path? files[filepath] = SourceFile(filepath, content, cfg.exclude) # TODO: Chop path?
print print
@@ -200,7 +208,7 @@ def run (sourceDirectory, outputFilename = None, configFile = None,
if os.path.exists(fullpath): if os.path.exists(fullpath):
print "Importing: %s" % path print "Importing: %s" % path
content = open(fullpath, "U").read() # TODO: Ensure end of line @ EOF? content = open(fullpath, "U").read() # TODO: Ensure end of line @ EOF?
files[path] = SourceFile(path, content) # TODO: Chop path? files[path] = SourceFile(path, content, cfg.exclude) # TODO: Chop path?
else: else:
raise MissingImport("File '%s' not found (required by '%s')." % (path, filepath)) raise MissingImport("File '%s' not found (required by '%s')." % (path, filepath))
@@ -229,6 +237,9 @@ def run (sourceDirectory, outputFilename = None, configFile = None,
for fp in order: for fp in order:
fName = os.path.normpath(os.path.join(sourceDirectory, fp)).replace("\\","/") fName = os.path.normpath(os.path.join(sourceDirectory, fp)).replace("\\","/")
print "Append: ", fName print "Append: ", fName
f = files[fp]
for fExclude in f.excludedFiles:
print " Required file \"%s\" is excluded." % fExclude
result.append(fName) result.append(fName)
print "\nTotal files: %d " % len(result) print "\nTotal files: %d " % len(result)
return result return result
@@ -237,6 +248,8 @@ def run (sourceDirectory, outputFilename = None, configFile = None,
for fp in order: for fp in order:
f = files[fp] f = files[fp]
print "Exporting: ", f.filepath print "Exporting: ", f.filepath
for fExclude in f.excludedFiles:
print " Required file \"%s\" is excluded." % fExclude
result.append(HEADER % f.filepath) result.append(HEADER % f.filepath)
source = f.source source = f.source
result.append(source) result.append(source)