view pylearn/datasets/config.py @ 818:f4729745bb58

backporting to 2.4
author dumitru@deepnets.mtv.corp.google.com
date Wed, 02 Sep 2009 14:22:02 -0700
parents 14d22ca1c8b5
children 039e93a95c20
line wrap: on
line source

"""Configuration options for datasets


Especially, the locations of data files.
"""

import os, sys
def env_get(key, default, key2 = None):
    if key2 and os.getenv(key) is None:
        key=key2
    if os.getenv(key) is None:
        print >> sys.stderr, "WARNING: Environment variable", key,
        print >> sys.stderr, "is not set. Using default of", default
    if os.getenv(key) is None:
      return default
    else:
      return os.getenv(key)
    #return default if os.getenv(key) is None else os.getenv(key)

def data_root():
    return env_get('PYLEARN_DATA_ROOT', os.getenv('HOME')+'/data', 'DBPATH')