Exemplo n.º 1
0
def buildStream(stripping, streamName=''):
    """
    Create a StrippingStream from the lineBuilder database
    Usage:
    >>> streamDimuon = strippingStream('Stripping13','Dimuon')
    or:
    >>> conf = strippingConfiguration('Stripping13')
    >>> streamDimuon = strippingStream(conf,'Dimuon')
    
    """

    from StrippingConf.StrippingStream import StrippingStream
    from StrippingSettings.Utils import strippingConfiguration
    from StrippingSelections import lineBuilders

    stream = StrippingStream(streamName)

    if isinstance(stripping, basestring):
        _db = strippingConfiguration(stripping)
    else:
        _db = stripping

    for key in _db.keys():
        _conf = _db[key]
        if stream.name() in _conf['STREAMS']:
            _lb = lineBuilders()[_conf['BUILDERTYPE']](key, _conf['CONFIG'])
            stream.appendLines(_lb.lines())
    return stream
Exemplo n.º 2
0
def buildStream(stripping, streamName='', WGs=None):
    """
    Create a StrippingStream from the lineBuilder database
    Usage:
    >>> streamDimuon = strippingStream('Stripping13','Dimuon')
    or:
    >>> conf = strippingConfiguration('Stripping13')
    >>> streamDimuon = strippingStream(conf,'Dimuon')

    """

    from StrippingConf.StrippingStream import StrippingStream
    from StrippingSettings.Utils import strippingConfiguration
    from StrippingSelections import lineBuilders
    from StrippingUtils.Utils import lineFromName

    stream = StrippingStream(streamName)

    if isinstance(stripping, basestring):
        _db = strippingConfiguration(stripping)
    else:
        _db = stripping

    for key in _db.keys():
        _conf = _db[key]
        if stream.name() in _conf['STREAMS']:
            if WGs and not any(WG for WG in _conf['WGs'] if WG in WGs):
                continue
            _lb = lineBuilders()[_conf['BUILDERTYPE']](key, _conf['CONFIG'])

            if isinstance(_conf['STREAMS'], dict):
                for linename in _conf['STREAMS'][stream.name()]:
                    line = lineFromName(_lb, linename)
                    if line:
                        stream.appendLines([line])
                    else:
                        raise Exception(
                            'The line you have requested does not exist ' +
                            linename)
            elif isinstance(_conf['STREAMS'], list):
                stream.appendLines(_lb.lines())
            else:
                raise Exception('Unsupported type, expected list ' +
                                'or dict for line-to-STREAM mapping')
    return stream