Esempio n. 1
0
    def from_dict(self, teststr, cd, kw):
        start = dictgetter(cd, ('start', 'start_count'), default=50)
        freq = cd.get('frequency', 1)
        win = cd.get('window', 0)
        mapper = cd.get('mapper', '')

        ntrips = cd.get('ntrips', 1)

        analysis_types = cd.get('analysis_types', [])
        if analysis_types:
            analysis_types = [
                a.lower().replace(' ', '_') for a in analysis_types
            ]
        else:
            analysis_types = []

        attr = extract_attr(teststr)

        self.trait_set(start_count=start,
                       frequency=freq,
                       attr=attr,
                       window=win,
                       mapper=mapper,
                       ntrips=ntrips,
                       analysis_types=analysis_types,
                       **kw)
        self._from_dict_hook(cd)
Esempio n. 2
0
    def from_dict(self, teststr, cd, kw):
        start = dictgetter(cd, ('start', 'start_count'), default=50)
        freq = cd.get('frequency', 1)
        win = cd.get('window', 0)
        mapper = cd.get('mapper', '')

        ntrips = cd.get('ntrips', 1)

        analysis_types = cd.get('analysis_types')
        if analysis_types:
            analysis_types = [a.lower() for a in analysis_types]
        attr = extract_attr(teststr)

        self.trait_set(start_count=start, frequency=freq,
                       attr=attr,
                       window=win, mapper=mapper,
                       ntrips=ntrips, analysis_types=analysis_types,
                       **kw)
        self._from_dict_hook(cd)
Esempio n. 3
0
def conditional_from_dict(cd, klass, level=None, location=None):
    if isinstance(klass, str):
        klass = globals()[klass]

    # try:
    # teststr = cd['teststr']
    # except KeyError:
    # #for pre 2.0.5 conditionals files
    # teststr = cd.get('check')
    # if not teststr:
    # return

    # attr = cd.get('attr')
    # if not attr:
    # return
    teststr = dictgetter(cd, ('teststr', 'comp', 'check'))
    if not teststr:
        return

    start = dictgetter(cd, ('start', 'start_count'), default=50)
    freq = cd.get('frequency', 1)
    win = cd.get('window', 0)
    mapper = cd.get('mapper', '')
    action = cd.get('action', '')
    ntrips = cd.get('ntrips', 1)
    analysis_types = cd.get('analysis_types')
    if analysis_types:
        analysis_types = [a.lower() for a in analysis_types]
    attr = extract_attr(teststr)
    cx = klass(teststr, start_count=start, frequency=freq,
               attr=attr,
               window=win, mapper=mapper, action=action, ntrips=ntrips, analysis_types=analysis_types)
    if level:
        cx.level = level
    if location:
        location = os.path.relpath(location, paths.root_dir)
        cx.location = location

    return cx