configuration.py 742 B

12345678910111213141516171819202122232425
  1. from collections import Counter
  2. from dataclasses import dataclass, field
  3. from typing import Iterable, List
  4. from graph_exploring_tool.query import Prefix
  5. def get_duplicates(candidates: Iterable) -> List:
  6. for key, count in Counter(candidates).items():
  7. if count > 1:
  8. yield key
  9. @dataclass(init=True, repr=True, order=False, frozen=True)
  10. class Configuration:
  11. endpoint_sparql: str = ""
  12. example_prefix: str = ""
  13. example_query: str = ""
  14. prefixes: List[Prefix] = field(default_factory=list)
  15. def check_for_duplicate_prefixes(self):
  16. """"""
  17. yield from get_duplicates(prefix.name for prefix in self.prefixes)
  18. yield from get_duplicates(prefix.namespace for prefix in self.prefixes)