12345678910111213141516171819202122232425 |
- from collections import Counter
- from dataclasses import dataclass, field
- from typing import Iterable, List
- from graph_exploring_tool.query import Prefix
- def get_duplicates(candidates: Iterable) -> List:
- for key, count in Counter(candidates).items():
- if count > 1:
- yield key
- @dataclass(init=True, repr=True, order=False, frozen=True)
- class Configuration:
- endpoint_sparql: str = ""
- example_prefix: str = ""
- example_query: str = ""
- prefixes: List[Prefix] = field(default_factory=list)
- def check_for_duplicate_prefixes(self):
- """"""
- yield from get_duplicates(prefix.name for prefix in self.prefixes)
- yield from get_duplicates(prefix.namespace for prefix in self.prefixes)
|