Project

General

Profile

« Previous | Next » 

Revision 933

ch_root: Fixed detection of unset env vars so that usage message is printed when any option is missing

View differences:

ch_root
10 10

  
11 11
import opts
12 12

  
13
def all_not_none(list_):
14
    return reduce(lambda a, b: a and b, map(lambda e: e != None, list_))
15

  
16 13
def main():
17 14
    # Get config from env vars
18
    config_names = ['in_root', 'out_root']
19 15
    env_names = []
20
    configs = map(lambda col: opts.get_env_vars(config_names, col, env_names),
21
        ['left', 'right'])
22
    if not all_not_none(configs): raise SystemExit(
16
    print_usage_ref = [False]
17
    def on_unset(e): print_usage_ref[0] = True
18
    configs = [opts.get_env_vars(['in_root', 'out_root'], col, env_names,
19
        on_unset) for col in ['left', 'right']]
20
    if print_usage_ref[0]: raise SystemExit(
23 21
        'Usage: '+opts.env_usage(env_names)+' '+sys.argv[0]+' <in_map >out_map')
24 22
    
25 23
    # Transform map

Also available in: Unified diff