Skip to content

Commit

Permalink
Windows fix for FormatCBFMini (#742)
Browse files Browse the repository at this point in the history
If data were collected on a Windows system, then ":" may exist in the file path, not just the timestamp.
  • Loading branch information
dagewa committed Jul 23, 2024
1 parent 4e46bec commit 3102224
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions newsfragments/742.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
``FormatCBFMini``: when parsing header lines for a timestamp, avoid clashes with Windows paths.

12 changes: 10 additions & 2 deletions src/dxtbx/format/FormatCBFMini.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ def _get_timestamp_from_raw_header(
header = header.splitlines()
timestamp = None
for record in header:
if len(record[1:].split()) <= 2 and record.count(":") == 2:
if (
len(record[1:].split()) <= 2
and record.count(":") == 2
and "Image_path" not in record
):
timestamp = datetime.datetime.fromisoformat(record[1:].strip())
break
return timestamp
Expand All @@ -100,7 +104,11 @@ def _start(self):
if record[:1] != "#":
continue

if len(record[1:].split()) <= 2 and record.count(":") == 2:
if (
len(record[1:].split()) <= 2
and record.count(":") == 2
and "Image_path" not in record
):
self._cif_header_dictionary["timestamp"] = record[1:].strip()
continue

Expand Down

0 comments on commit 3102224

Please sign in to comment.