Configuring XML parsing options readded after it was temporarily removed in recent config restructuring.

This commit is contained in:
Zaid Abdulla committed 2014-08-01 13:17:34 +03:00
1 parent 97700eb6c8
commit d68b9d40ea
1 file changed
+26 -9
+26 -9
View File
@@ -55,6 +55,28 @@ defaults = {
TASK_PARAMETERS_BATCH_SIZE : 32 TASK_PARAMETERS_BATCH_SIZE : 32
} }
exports.LIBXMLJS_OPTIONS = {}
setConfig = (name, value) ->
return true if exports[name]?
_value = null
if defaults[name]?
_value = common.matchType(defaults[name], value)
else if common.startsWith(name, 'XML_PARSE_')
n = name[10..].toLowerCase() # libxmljs' options are lower case
_value = common.matchType(true, value)
exports.LIBXMLJS_OPTIONS[n] = _value
if _value?
exports[name] = _value
# Save as environmnet variable to pass on to any child processes
process.env["GENIEACS_#{name}"] = _value
return _value?
# Command line arguments # Command line arguments
exports.argv = [] exports.argv = []
@@ -65,10 +87,7 @@ while argv.length
v = argv.shift() v = argv.shift()
exports.argv[arg] = v exports.argv[arg] = v
n = arg[2..].toUpperCase().replace(/-/g, '_') n = arg[2..].toUpperCase().replace(/-/g, '_')
if defaults[n]? setConfig(n, v)
exports[n] ?= common.matchType(defaults[n], v)
# Save as environmnet variables to pass on to any child processes
process.env["GENIEACS_#{n}"] = v
else else
exports.argv.push(arg) exports.argv.push(arg)
@@ -76,8 +95,7 @@ while argv.length
# Environment variable # Environment variable
for k, v of process.env for k, v of process.env
k = k[9..] # remove "GENIEACS_" prefix k = k[9..] # remove "GENIEACS_" prefix
if defaults[k]? setConfig(k, v)
exports[k] ?= common.matchType(defaults[k], v)
# Find config dir # Find config dir
@@ -91,13 +109,12 @@ else
# Configuration file # Configuration file
for k, v of require(path.resolve(exports.CONFIG_DIR, 'config')) for k, v of require(path.resolve(exports.CONFIG_DIR, 'config'))
if defaults[k]? setConfig(k, v)
exports[k] ?= common.matchType(defaults[k], v)
# Defaults # Defaults
for k, v of defaults for k, v of defaults
exports[k] ?= defaults[k] setConfig(k, v)
# load parameter configurations # load parameter configurations