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')
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")
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
def str_to_regex_case(input, output): eq_(str_to_regex(input), output)