def try_parse_object(v): if isinstance(v, basestring): if v.startswith('REGEX:'): _, flags, pattern = v.split(':', 2) return re.compile(pattern, int(flags or 0)) elif v.startswith('DATET:'): _, pattern = v.split(':', 1) return dateutil.parser.parse(pattern) elif v.startswith('LEVEL:'): _, name, value = v.split(':', 2) return level(name, value) elif v.startswith('CPUMASK:'): _, value = v.split(':', 1) return cpu_mask(value) return v
def _wa_cpu_mask_constructor(loader, node): value = loader.construct_scalar(node) return cpu_mask(value)