Exemplo n.º 1
0
Arquivo: nag.py Projeto: DJStill/ahm16
def search_person_ids(person_regex, event, search_names=False):
    person_ids = []
    r = re.compile(person_regex, re.I)
    for person_id, person in event['people'].items():
        to_search = person_id
        if search_names:
            to_search = person['name']
        if r.search(to_search):
            person_ids.append(person_id)
    if not person_ids:
        label = "person names" if search_names else "person_ids"
        error("No %s matching %r.", label, person_regex)
    return set(person_ids)
Exemplo n.º 2
0
def search_person_ids(person_regex, event, search_names=False):
    person_ids = []
    r = re.compile(person_regex, re.I)
    for person_id, person in event['people'].items():
        to_search = person_id
        if search_names:
            to_search = person['name']
        if r.search(to_search):
            person_ids.append(person_id)
    if not person_ids:
        label = "person names" if search_names else "person_ids"
        error("No %s matching %r.", label, person_regex)
    return set(person_ids)
Exemplo n.º 3
0
Arquivo: nag.py Projeto: DJStill/ahm16
def get_person_ids(options, event):
    p1 = p2 = None
    if options.person_id is not None:
        p1 = search_person_ids(options.person_id, event)
    if options.name is not None:
        p2 = search_person_ids(options.name, event, search_names=True)
    if p1 and p2: 
        person_ids = p1 & p2
        if not person_ids:
            error("No persons matching id %r and name %r", options.person_id, options.name)
        return person_ids
    if p2 is None:
        return p1
    return p2
Exemplo n.º 4
0
def get_person_ids(options, event):
    p1 = p2 = None
    if options.person_id is not None:
        p1 = search_person_ids(options.person_id, event)
    if options.name is not None:
        p2 = search_person_ids(options.name, event, search_names=True)
    if p1 and p2:
        person_ids = p1 & p2
        if not person_ids:
            error("No persons matching id %r and name %r", options.person_id,
                  options.name)
        return person_ids
    if p2 is None:
        return p1
    return p2
Exemplo n.º 5
0
Arquivo: nag.py Projeto: DJStill/ahm16
def get_tests(testspec):
    tests = set(testspec.split(','))
    if 'all' in tests:
        tests |= set(TESTS.keys())
        tests.remove('all')
    for metatest in (tests & set(METATESTS.keys())):
        tests |= set(METATESTS[metatest]['tests'])
        tests.remove(metatest)
    for subtract in [t for t in tests if t.startswith('-')]:
        tests.remove(subtract)
        test = subtract[1:]
        if test in METATESTS:
            tests -= set(METATESTS[test]['tests'])
        else:
            tests.remove(test)
    bad = tests - set(TESTS.keys())
    if bad:
        error("Unknown test(s): %r", ','.join(bad))
    return tests
Exemplo n.º 6
0
def get_tests(testspec):
    tests = set(testspec.split(','))
    if 'all' in tests:
        tests |= set(TESTS.keys())
        tests.remove('all')
    for metatest in (tests & set(METATESTS.keys())):
        tests |= set(METATESTS[metatest]['tests'])
        tests.remove(metatest)
    for subtract in [t for t in tests if t.startswith('-')]:
        tests.remove(subtract)
        test = subtract[1:]
        if test in METATESTS:
            tests -= set(METATESTS[test]['tests'])
        else:
            tests.remove(test)
    bad = tests - set(TESTS.keys())
    if bad:
        error("Unknown test(s): %r", ','.join(bad))
    return tests