def parse_core_link_format(link_format, root): while len(link_format) > 0: pattern = "<([^>]*)>;" result = re.match(pattern, link_format) path = result.group(1) path = path.split("/") path = path[1:] link_format = link_format[result.end(1) + 2:] pattern = "([^<,])*" result = re.match(pattern, link_format) attributes = result.group(0) dict_att = {} if len(attributes) > 0: attributes = attributes.split(";") for att in attributes: a = att.split("=") # TODO check correctness dict_att[a[0]] = a[1] link_format = link_format[result.end(0) + 1:] while True: last, p = root.find_complete_last(path) if p is not None: resource = Resource("/".join(path)) resource.path = p if p == "".join(path): resource.attributes = dict_att last.add_child(resource) else: break log.msg(root.dump()) return root