Revision 64
Added by Aaron Marcuse-Kubitza about 13 years ago
map | ||
---|---|---|
10 | 10 |
|
11 | 11 |
sys.path.append(os.path.dirname(__file__)+"/lib") |
12 | 12 |
|
13 |
def env_flag(name): return name in os.environ and os.environ[name] != ''
|
|
13 |
import opts
|
|
14 | 14 |
|
15 | 15 |
def main(): |
16 | 16 |
# Get db config from env vars |
17 | 17 |
db_config_names = ['host', 'user', 'password', 'database'] |
18 | 18 |
env_names = [] |
19 | 19 |
def get_db_config(prefix): |
20 |
has_all = True |
|
21 |
db_config = {} |
|
22 |
for name in db_config_names: |
|
23 |
env_name = prefix+'_'+name |
|
24 |
env_names.append(env_name) |
|
25 |
if env_name in os.environ: db_config[name] = os.environ[env_name] |
|
26 |
else: has_all = False |
|
27 |
if has_all: return db_config |
|
28 |
else: return None |
|
20 |
return opts.get_env_vars(db_config_names, prefix, env_names) |
|
29 | 21 |
from_db_config = get_db_config('from') |
30 | 22 |
to_db_config = get_db_config('to') |
31 | 23 |
in_is_db = from_db_config != None |
... | ... | |
39 | 31 |
if uses_map: raise SystemExit('Usage: env'+''.join(map(lambda name: |
40 | 32 |
' ['+name+'=...]', env_names))+' [commit=1] '+prog_name |
41 | 33 |
+' [map_path] [<input] [>output]') |
42 |
commit = env_flag('commit') |
|
34 |
commit = opts.env_flag('commit')
|
|
43 | 35 |
|
44 | 36 |
# Load map header |
45 | 37 |
in_is_xml = True |
Also available in: Unified diff
Moved options-processing code to opts.py