def parse_replace_expr(rawvalue, field):
    found = parse_conf_fields(rawvalue, 2, field)
    pairs = []
    for rawexpr, repl in found:
        expr = compile_conf_re(rawexpr, field)
        pairs.append((expr, repl))
    return pairs
    def test_parsing_conf_fields(self):
        class DummyLogger:

            def __init__(self):
                self.calls = []

            def warn(self, fmt, *args):
                self.calls.append(fmt % args)
        configutil.logger = DummyLogger() # !!!!
        res = configutil.parse_conf_fields("", 1, "fieldname")
        self.assertEquals(res, [])
        res = configutil.parse_conf_fields("single", 1, "fieldname")
        self.assertEquals(res, [["single"]])
        res = configutil.parse_conf_fields("not single", 1, "fieldname")
        self.assertEquals(configutil.logger.calls,
                ["expected 1 fields in fieldname entry: not single"])
        self.assertEquals(res, [])
        res = configutil.parse_conf_fields("not single", 2, "fieldname")
        self.assertEquals(res, [["not", "single"]])
Exemple #3
0
 def _parse_devs(class_, rawvalue):
     import stat
     typemap = {"b": stat.S_IFBLK, "c": stat.S_IFCHR}
     rawdevs = parse_conf_fields(rawvalue, 5, "devices")
     devs = []
     try:
         devs = [(name, typemap[type], int(rawmajor), int(rawminor),
                  int(rawmode, 8))
                 for (name, type, rawmajor, rawminor, rawmode) in rawdevs]
     except KeyError:
         logger.warn("invalid type for device in list of devices: %s",
                 rawvalue)
     except ValueError:
         logger.warn("invalid integer in list of devices: %s", rawvalue)
     return devs
def split_extra_macros(rawvalue, field):
    return parse_conf_fields(rawvalue, 2, field)
Exemple #5
0
 def _parse_binds(class_, rawvalue):
     return parse_conf_fields(rawvalue, 2, "binds")
Exemple #6
0
 def _parse_mount_points(class_, rawvalue):
     return parse_conf_fields(rawvalue, 4, "mountpoint")