Adding support for excluding directories when an includes list is not explicitly provided. For our full.cfg example profile, we can exclude the OpenLayers/Lang and Firebug directories instead of having to explicitly list language files to exclude (see #2871).

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10816 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2010-10-11 15:51:29 +00:00
parent 5ec2f0371d
commit 8047afd909
2 changed files with 18 additions and 17 deletions

View File

@@ -14,19 +14,5 @@ Rico/Corner.js
[include]
[exclude]
Firebug/firebug.js
Firebug/firebugx.js
OpenLayers/Lang/ca.js
OpenLayers/Lang/cs-CZ.js
OpenLayers/Lang/da-DK.js
OpenLayers/Lang/de.js
OpenLayers/Lang/en-CA.js
OpenLayers/Lang/es.js
OpenLayers/Lang/fr.js
OpenLayers/Lang/it.js
OpenLayers/Lang/nb.js
OpenLayers/Lang/nl.js
OpenLayers/Lang/pt-BR.js
OpenLayers/Lang/sv-SE.js
OpenLayers/Lang/zh-TW.js
OpenLayers/Lang/zh-CN.js
Firebug
OpenLayers/Lang

View File

@@ -94,6 +94,7 @@ class Config:
[exclude]
3rd/logger.js
exclude/this/dir
All headings are required.
@@ -122,6 +123,20 @@ class Config:
self.include = lines[lines.index("[include]") + 1:lines.index("[exclude]")]
self.exclude = lines[lines.index("[exclude]") + 1:]
def undesired(filepath, excludes):
# exclude file if listed
exclude = filepath in excludes
if not exclude:
# check if directory is listed
for excludepath in excludes:
if not excludepath.endswith("/"):
excludepath += "/"
if filepath.startswith(excludepath):
exclude = True
break
return exclude
def run (sourceDirectory, outputFilename = None, configFile = None):
cfg = None
if configFile:
@@ -138,7 +153,7 @@ def run (sourceDirectory, outputFilename = None, configFile = None):
if cfg and cfg.include:
if filepath in cfg.include or filepath in cfg.forceFirst:
allFiles.append(filepath)
elif (not cfg) or (filepath not in cfg.exclude):
elif (not cfg) or (not undesired(filepath, cfg.exclude)):
allFiles.append(filepath)
## Header inserted at the start of each file in the output