diff --git a/src/macrogen/graph.py b/src/macrogen/graph.py index a279df6..0952c81 100644 --- a/src/macrogen/graph.py +++ b/src/macrogen/graph.py @@ -246,6 +246,10 @@ def _build_index(self): def _augment_details(self): logger.info('Augmenting refs with data from graphs') for index, ref in enumerate(self.order_refs(), start=1): + if ref not in self.dag: + ref.earliest = EARLIEST + ref.latest = LATEST + continue ref.index = index ref.rank = self.closure.in_degree(ref) max_before_date = max((d for d, _ in self.closure.in_edges(ref) if isinstance(d, date)), @@ -287,7 +291,8 @@ def save(self, outfile: Path): pickle.dump(self.simple_cycles, sc_entry) with zip.open('order.json', 'w') as order_entry: text = TextIOWrapper(order_entry, encoding='utf-8') - json.dump([ref.uri for ref in self.order], text) + json.dump([ref.uri for ref in self.order], text, indent=True) + text.flush() with zip.open('config.yaml', 'w') as config_entry: config.save_config(config_entry) with zip.open('base.yaml', 'w') as base_entry: @@ -303,7 +308,8 @@ def _load_from(self, load_from: Path): with zip.open('simple_cycles.pickle', 'r') as sc_entry: self.simple_cycles = pickle.load(sc_entry) with zip.open('order.json', 'r') as order_entry: - uris = json.load(order_entry) + text = TextIOWrapper(order_entry, encoding='utf-8') + uris = json.load(text) self.order = [Witness.get(uri) for uri in uris] self._build_index() diff --git a/src/macrogen/report.py b/src/macrogen/report.py index 41b68cf..b457059 100644 --- a/src/macrogen/report.py +++ b/src/macrogen/report.py @@ -1215,7 +1215,7 @@ def rel_scenes(ref: Reference) -> List[str]: if ref.earliest > EARLIEST and ref.latest < LATEST] with (config.path.report_dir / 'timeline.json').open("wt") as data_out: json.dump(data, data_out) - (config.path.report_dir / 'timeline.html').write_binary(pkg_resources.resource_string('macrogen', 'timeline.html')) + (config.path.report_dir / 'timeline.html').write_bytes(pkg_resources.resource_string('macrogen', 'timeline.html')) def report_inscriptions(info: MacrogenesisInfo):