Skip to content

Commit

Permalink
Fixes zip file with report files
Browse files Browse the repository at this point in the history
  • Loading branch information
dkratzert committed Oct 30, 2023
1 parent 9afd051 commit dcd7c25
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions finalcif/appwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1139,9 +1139,8 @@ def make_report_tables(self) -> None:
return
if not self.running_inside_unit_test:
self.open_report_document(report_filename, multi_table_document)
print('dbg> disabled temporarily!')
# Save report and other files to a zip file:
# self.zip_report(report_filename)
self.zip_report(report_filename)

def report_without_template(self) -> bool:
"""Check whether the report is generated from a template or hard-coded"""
Expand All @@ -1152,7 +1151,7 @@ def zip_report(self, report_filename: Path) -> None:
from finalcif.report.archive_report import ArchiveReport
zipfile = self.cif.finalcif_file.with_suffix('.zip')
if zipfile.exists():
zipname = next_path(zipfile.stem + '-%s.zip')
zipname = next_path(str(zipfile.parent / Path(zipfile.stem + '-%s.zip')))
zipfile = zipfile.parent.joinpath(zipname)
with suppress(Exception):
arc = ArchiveReport(zipfile)
Expand Down
4 changes: 2 additions & 2 deletions finalcif/tools/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ def next_path(path_pattern: str) -> str:
"""
i = 1
# First do an exponential search
while path.exists(path_pattern % i):
while os.path.exists(path_pattern % i):
i = i * 2
# Result lies somewhere in the interval (i/2..i]
# We call this interval (a..b] and narrow it down until a + 1 = b
a, b = (i // 2, i)
while a + 1 < b:
c = (a + b) // 2 # interval midpoint
a, b = (c, b) if path.exists(path_pattern % c) else (a, c)
a, b = (c, b) if os.path.exists(path_pattern % c) else (a, c)
return path_pattern % b


Expand Down

0 comments on commit dcd7c25

Please sign in to comment.