def _match_pathpart(routemap, part): #wrap schema and pathpart in a list because Form cannot handle naked values. subject = [part] for key in routemap: validator = Form([key]) if validator.validate(subject): return validator.cleaned[0], routemap[key]
def _fill_path(path, path_args): filled_path = [] for pathpart in path: if isinstance(pathpart, str): filled_path.append(pathpart) else: validator = Form([pathpart]) if not validator.validate([next(path_args)]): return False filled_path.append(validator.cleaned[0]) return filled_path