Ejemplo n.º 1
0
def test_str_to_regex_usage():
    filename = "/data/nfsen/profiles/live/podium/nfcapd.201109010000"

    regex = str_to_regex("profiles/:profile/:source/nfcapd")

    groups = re.search(regex, filename).groupdict()
    eq_(groups['profile'], 'live')
    eq_(groups['source'], 'podium')
Ejemplo n.º 2
0
def test_str_to_regex_usage():
    filename = "/data/nfsen/profiles/live/podium/nfcapd.201109010000"

    regex = str_to_regex("profiles/:profile/:source/nfcapd")

    groups = re.search(regex, filename).groupdict()
    eq_(groups["profile"], "live")
    eq_(groups["source"], "podium")
Ejemplo n.º 3
0
def read_config(fn):
    now = datetime.datetime.now() - datetime.timedelta(minutes=10)

    defaults = {
        'year':     str(now.year),
        'month':    "%02d" % now.month,
        'day':      "%02d" % now.day,
        'hour':     "%02d" % now.hour,
    }
    c = ConfigParser.ConfigParser(defaults=defaults)
    f = open(fn)
    c.readfp(f)
    f.close()
    config = dict(c.items("nfi"))
    if 'pathregex' in config:
        if ':' in config['pathregex']:
            config['pathregex'] = str_to_regex(config['pathregex'])
        config['pathregex'] = re.compile(config['pathregex'])

    return config
Ejemplo n.º 4
0
def read_config(fn):
    now = datetime.datetime.now() - datetime.timedelta(minutes=10)

    defaults = {
        'year': str(now.year),
        'month': "%02d" % now.month,
        'day': "%02d" % now.day,
        'hour': "%02d" % now.hour,
    }
    c = ConfigParser.ConfigParser(defaults=defaults)
    f = open(fn)
    c.readfp(f)
    f.close()
    config = dict(c.items("nfi"))
    if 'pathregex' in config:
        if ':' in config['pathregex']:
            config['pathregex'] = str_to_regex(config['pathregex'])
        config['pathregex'] = re.compile(config['pathregex'])

    return config
Ejemplo n.º 5
0
def str_to_regex_case(input, output):
    eq_(str_to_regex(input), output)
Ejemplo n.º 6
0
def str_to_regex_case(input, output):
    eq_(str_to_regex(input), output)