Project

General

Profile

« Previous | Next » 

Revision 945

opts.py: env_flag(): Added support for default value if unset

View differences:

lib/opts.py
4 4

  
5 5
import util
6 6

  
7
def env_flag(name, env_names_ref=None):
7
def env_flag(name, default=False, env_names_ref=None):
8 8
    if env_names_ref != None: env_names_ref.append(name+'=1')
9
    return name in os.environ and os.environ[name] != ''
9
    return bool(os.getenv(name, default))
10 10

  
11 11
def get_env_var(name, default, env_names_ref=None):
12 12
    if env_names_ref != None: env_names_ref.append(name+'=...')

Also available in: Unified diff