Merge "3496.1.patch" with current truck in GitHub
This commit is contained in:
@@ -53,12 +53,21 @@ class SourceFile:
|
||||
Represents a Javascript source code file.
|
||||
"""
|
||||
|
||||
def __init__(self, filepath, source):
|
||||
def __init__(self, filepath, source, cfgExclude):
|
||||
"""
|
||||
"""
|
||||
self.filepath = filepath
|
||||
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 = []
|
||||
|
||||
|
||||
@@ -67,8 +76,7 @@ class SourceFile:
|
||||
Extracts the dependencies specified in the source code and returns
|
||||
a list of them.
|
||||
"""
|
||||
# TODO: Cache?
|
||||
return re.findall(RE_REQUIRE, self.source)
|
||||
return self.requiredFiles
|
||||
|
||||
requires = property(fget=_getRequirements, doc="")
|
||||
|
||||
@@ -176,7 +184,7 @@ def run (sourceDirectory, outputFilename = None, configFile = None,
|
||||
print "Importing: %s" % filepath
|
||||
fullpath = os.path.join(sourceDirectory, filepath).strip()
|
||||
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
|
||||
|
||||
@@ -200,7 +208,7 @@ def run (sourceDirectory, outputFilename = None, configFile = None,
|
||||
if os.path.exists(fullpath):
|
||||
print "Importing: %s" % path
|
||||
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:
|
||||
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:
|
||||
fName = os.path.normpath(os.path.join(sourceDirectory, fp)).replace("\\","/")
|
||||
print "Append: ", fName
|
||||
f = files[fp]
|
||||
for fExclude in f.excludedFiles:
|
||||
print " Required file \"%s\" is excluded." % fExclude
|
||||
result.append(fName)
|
||||
print "\nTotal files: %d " % len(result)
|
||||
return result
|
||||
@@ -237,6 +248,8 @@ def run (sourceDirectory, outputFilename = None, configFile = None,
|
||||
for fp in order:
|
||||
f = files[fp]
|
||||
print "Exporting: ", f.filepath
|
||||
for fExclude in f.excludedFiles:
|
||||
print " Required file \"%s\" is excluded." % fExclude
|
||||
result.append(HEADER % f.filepath)
|
||||
source = f.source
|
||||
result.append(source)
|
||||
|
||||
Reference in New Issue
Block a user