DataPipeline/Utilities.py
def createConfigParserfromDict(data, sections, **kwargs):
    """Helper method to create a ConfigParser from a dict and/or keywords"""

    cp = ConfigParser.ConfigParser()
    for s in sections:
        cp.add_section(s)
        if not data.has_key(s):
            continue
        for i in data[s]:
            name,val = i
            cp.set(s, name, val)

    #use kwargs to create specific settings in the appropriate section
    for s in cp.sections():
        opts = cp.options(s)
        for k in kwargs:
            if k in opts:
                cp.set(s, k, kwargs[k])
    #handle model and variable sections which can have zero or multiple
    #options
    for k in sorted(kwargs):
        if k.startswith('model'):
            cp.set('models', k, kwargs[k])
        elif k.startswith('variable'):
            cp.set('variables', k, kwargs[k])
        elif k.startswith('function'):
            cp.set('functions', k, kwargs[k])
    return cp
Helper method to create a ConfigParser from a dict and/or keywords
Helper method to create a ConfigParser from a dict and/or keywords
Helper method to create a ConfigParser from a dict and / or keywords
def createConfigParserfromDict(data, sections, **kwargs):
    cp = ConfigParser.ConfigParser()
    for s in sections:
        cp.add_section(s)
        if not data.has_key(s):
            continue
        for i in data[s]:
            name,val = i
            cp.set(s, name, val)
    for s in cp.sections():
        opts = cp.options(s)
        for k in kwargs:
            if k in opts:
                cp.set(s, k, kwargs[k])
    for k in sorted(kwargs):
        if k.startswith('model'):
            cp.set('models', k, kwargs[k])
        elif k.startswith('variable'):
            cp.set('variables', k, kwargs[k])
        elif k.startswith('function'):
            cp.set('functions', k, kwargs[k])
    return cp
def createConfigParserfromDict ( data , sections , ** kwargs ) : cp = ConfigParser . ConfigParser ( ) for s in sections : cp . add_section ( s ) if not data . has_key ( s ) : continue for i in data [ s ] : name , val = i cp . set ( s , name , val ) for s in cp . sections ( ) : opts = cp . options ( s ) for k in kwargs : if k in opts : cp . set ( s , k , kwargs [ k ] ) for k in sorted ( kwargs ) : if k . startswith ( 'model' ) : cp . set ( 'models' , k , kwargs [ k ] ) elif k . startswith ( 'variable' ) : cp . set ( 'variables' , k , kwargs [ k ] ) elif k . startswith ( 'function' ) : cp . set ( 'functions' , k , kwargs [ k ] ) return cp
Helper method to create a ConfigParser from a dict and/or keywords
Helper method to create a ConfigParser from a dict and / or keywords
"""Helper method to create a ConfigParser from a dict and/or keywords""" #use kwargs to create specific settings in the appropriate section #handle model and variable sections which can have zero or multiple #options
data
sections