Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(27)  |  Call(24)  |  Derive(0)  |  Import(3)
>>> class TestClass(object):
...   pass
>>> testClass = TestClass()
>>> testClass.a = 1
>>> testClass.b = "2"
>>> testClass.c = 3
>>> testClass.d = True
>>> buildParameters(testClass, ["a", "b"])
['--a', u'1', '--b', u'2']
(more...)

        def buildParameters(obj, validList):
    """
    >>> class TestClass(object):
    ...   pass
    >>> testClass = TestClass()
    >>> testClass.a = 1
    >>> testClass.b = "2"
    >>> testClass.c = 3
    >>> testClass.d = True
    >>> buildParameters(testClass, ["a", "b"])
    ['--a', u'1', '--b', u'2']

    >>> testClass.b = None
    >>> buildParameters(testClass, ["a", "b"])
    ['--a', u'1']

    The following shows support for boolean flags that don't have a value
    associated with them:

    >>> buildParameters(testClass, ["a", "d"])
    ['--a', u'1', '--d']
    """
    params = []
    for param in validList:
        attr = getattr(obj, param)
        if attr:
            param = param.replace("_", "-")
            if isinstance(attr, bool):
                attr = ""
            params.extend(["--%s" % param, unicode(attr)])
    return [x for x in params if x]
        


src/p/y/PyRRD-0.1.0/pyrrd/backend/external.py   PyRRD(Download)
    if function == 'create':
        validParams = ['start', 'step']
        params = common.buildParameters(obj, validParams)
        data = [unicode(x) for x in obj.ds]
        data += [unicode(x) for x in obj.rra]
        return (obj.filename, params + data)
 
    if function == 'update':
        validParams = ['template']
        params = common.buildParameters(obj, validParams)
    if function == 'fetch':
        validParams = ['resolution', 'start', 'end']
        params = common.buildParameters(obj, validParams)
        return (obj.filename, obj.cf, params)
 
            'force_rules_legend', 'tabwidth', 'base', 'color', 'imgformat',
            'slope_mode']
        params = common.buildParameters(obj, validParams)
        data = [unicode(x) for x in obj.data]
        return (obj.filename, params + data)

src/p/y/pyrrd-fix-0.1.1/pyrrd/backend/external.py   pyrrd-fix(Download)
    if function == 'create':
        validParams = ['start', 'step']
        params = common.buildParameters(obj, validParams)
        data = [unicode(x) for x in obj.ds]
        data += [unicode(x) for x in obj.rra]
        return (obj.filename, params + data)
 
    if function == 'update':
        validParams = ['template']
        params = common.buildParameters(obj, validParams)
    if function == 'fetch':
        validParams = ['resolution', 'start', 'end']
        params = common.buildParameters(obj, validParams)
        return (obj.filename, [obj.cf] + params)
 
            'force_rules_legend', 'tabwidth', 'base', 'color', 'imgformat',
            'slope_mode']
        params = common.buildParameters(obj, validParams)
        data = [unicode(x) for x in obj.data]
        return (obj.filename, params + data)

src/p/y/pyrrd-HEAD/pyrrd/backend/external.py   pyrrd(Download)
    if function == 'create':
        validParams = ['start', 'step']
        params = common.buildParameters(obj, validParams)
        data = [unicode(x) for x in obj.ds]
        data += [unicode(x) for x in obj.rra]
        return (obj.filename, params + data)
 
    elif function == 'update':
        validParams = ['template']
        params = common.buildParameters(obj, validParams)
    elif function == 'fetch':
        validParams = ['resolution', 'start', 'end']
        params = common.buildParameters(obj, validParams)
        return (obj.filename, [obj.cf] + params)
 
            'force_rules_legend', 'tabwidth', 'base', 'color', 'imgformat',
            'slope_mode']
        params = common.buildParameters(obj, validParams)
        data = [unicode(x) for x in obj.data]
        return (obj.filename, params + data)

src/p/y/PyRRD-0.1.0/pyrrd/backend/bindings.py   PyRRD(Download)
 
from pyrrd.backend import external
from pyrrd.backend.common import buildParameters
 
 
    if function == 'create':
        validParams = ['start', 'step']
        params = buildParameters(obj, validParams)
        params += [unicode(x) for x in obj.ds]
        params += [unicode(x) for x in obj.rra]
        return (obj.filename, params)
 
    if function == 'update':
        validParams = ['template']
        params = buildParameters(obj, validParams)
    if function == 'fetch':
        validParams = ['resolution', 'start', 'end']
        params = buildParameters(obj, validParams)
        return (obj.filename, [obj.cf] + params)
 
            'force_rules_legend', 'tabwidth', 'base', 'color', 'imgformat',
            'slope_mode']
        params = buildParameters(obj, validParams)
        params += [unicode(x) for x in obj.data]
        return (obj.filename, params)

src/p/y/pyrrd-fix-0.1.1/pyrrd/backend/bindings.py   pyrrd-fix(Download)
 
from pyrrd.backend import external
from pyrrd.backend.common import buildParameters
 
 
    if function == 'create':
        validParams = ['start', 'step']
        params = buildParameters(obj, validParams)
        params += [unicode(x) for x in obj.ds]
        params += [unicode(x) for x in obj.rra]
        return (obj.filename, params)
 
    if function == 'update':
        validParams = ['template']
        params = buildParameters(obj, validParams)
    if function == 'fetch':
        validParams = ['resolution', 'start', 'end']
        params = buildParameters(obj, validParams)
        return (obj.filename, [obj.cf] + params)
 
            'force_rules_legend', 'tabwidth', 'base', 'color', 'imgformat',
            'slope_mode']
        params = buildParameters(obj, validParams)
        params += [unicode(x) for x in obj.data]
        return (obj.filename, params)

src/p/y/pyrrd-HEAD/pyrrd/backend/bindings.py   pyrrd(Download)
 
from pyrrd.backend import external
from pyrrd.backend.common import buildParameters
 
 
    if function == 'create':
        validParams = ['start', 'step']
        params = buildParameters(obj, validParams)
        params += [unicode(x) for x in obj.ds]
        params += [unicode(x) for x in obj.rra]
        return (obj.filename, params)
 
    if function == 'update':
        validParams = ['template']
        params = buildParameters(obj, validParams)
    if function == 'fetch':
        validParams = ['resolution', 'start', 'end']
        params = buildParameters(obj, validParams)
        return (obj.filename, [obj.cf] + params)
 
            'force_rules_legend', 'tabwidth', 'base', 'color', 'imgformat',
            'slope_mode']
        params = buildParameters(obj, validParams)
        params += [unicode(x) for x in obj.data]
        return (obj.filename, params)