diff --git a/src/macrogen/__init__.py b/src/macrogen/__init__.py index e69de29..3970e29 100644 --- a/src/macrogen/__init__.py +++ b/src/macrogen/__init__.py @@ -0,0 +1,2 @@ +from .graph import macrogenesis_graphs, BiblSource +from .uris import Reference, Witness, AmbiguousRef, Inscription diff --git a/src/macrogen/datings.py b/src/macrogen/datings.py index 2062687..82fd929 100644 --- a/src/macrogen/datings.py +++ b/src/macrogen/datings.py @@ -87,7 +87,7 @@ def _read_scores(): return scores -_bib_db = _parse_bibliography('https://raw.githubusercontent.com/faustedition/faust-gen-html/master/xslt/bibliography.xml') +bibliography = _parse_bibliography('https://raw.githubusercontent.com/faustedition/faust-gen-html/master/xslt/bibliography.xml') _bib_labels = { 'faust://self': 'Faustedition', @@ -112,7 +112,7 @@ def __init__(self, uri, detail=''): if detail is None: detail = '' self.detail = detail - self.weight = _bib_db[uri].weight if uri in _bib_db else 1 + self.weight = bibliography[uri].weight if uri in bibliography else 1 def __eq__(self, other): if isinstance(other, BiblSource): @@ -147,13 +147,20 @@ def citation(self): Example: Bohnenkamp 19994 """ - if self.uri in _bib_db: - return _bib_db[self.uri].citation + if self.uri in bibliography: + return bibliography[self.uri].citation elif self.uri in _bib_labels: return _bib_labels[self.uri] else: return self.filename + @property + def long_citation(self): + if self.uri in bibliography: + return bibliography[self.uri].reference + else: + return self.citation + class _AbstractDating(metaclass=ABCMeta): """ @@ -317,7 +324,7 @@ def add_to_graph(self, G: nx.MultiDiGraph) -> None: ignore=self.ignore) -def _parse_file(filename: str) -> Generator[_AbstractDating]: +def _parse_file(filename: str) -> Generator[_AbstractDating, None, None]: """ Parses the given macrogenesis XML file and returns the datings from there. Args: @@ -336,7 +343,7 @@ def _parse_file(filename: str) -> Generator[_AbstractDating]: logger.error(str(e)) -def _parse_files() -> Generator[_AbstractDating]: +def _parse_files() -> Generator[_AbstractDating, None, None]: """ Parses the files in the macrogenesis folder and returns the datings from there. Returns: diff --git a/src/macrogen/report.py b/src/macrogen/report.py index cc49edd..50b5b66 100644 --- a/src/macrogen/report.py +++ b/src/macrogen/report.py @@ -154,7 +154,7 @@ def _format_row(self, row: Iterable, **rowattrs) -> str: logger.exception('Error formatting row %s', row) return f'Error formatting row {row}' - def _format_rows(self, rows: Iterable[Iterable]) -> Generator[str]: + def _format_rows(self, rows: Iterable[Iterable]) -> Generator[str, None, None]: """Formats the given rows.""" for row in rows: yield self._format_row(row)