From 8047afd909c45b199665412518d08bc9487b93f4 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 11 Oct 2010 15:51:29 +0000 Subject: [PATCH] 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 --- build/full.cfg | 18 ++---------------- tools/mergejs.py | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/build/full.cfg b/build/full.cfg index 2e4df5277c..0a40f1b563 100644 --- a/build/full.cfg +++ b/build/full.cfg @@ -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 diff --git a/tools/mergejs.py b/tools/mergejs.py index 865081e1ac..5df91117c6 100755 --- a/tools/mergejs.py +++ b/tools/mergejs.py @@ -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