def handleDuplicate(acc: Iterable[MetadataItem], pair: MetadataItem) -> Iterable[MetadataItem]: name: str = first(pair) tag: Optional[Tag] = tagByName(tags, name) seenTagNames: Iterator[str] = map(first, acc) # Throw away pair if it has the same tag name as some already seen, known, unique directive: return acc if tag is not None and tag.unique and name in seenTagNames else list( acc) + [pair]
def withoutSurroundingSlashes(s: str) -> str: return first(re.subn(re.compile(r"^\/|\/$"), "", s))
def valueGetter_all(metadata: Metadata) -> Callable[[Tag], List[TagValue]]: return lambda tag: [ second(pair) for pair in metadata if first(pair) == tag.name ]