From 3102224d05d33616855936453af82f6849c5b93b Mon Sep 17 00:00:00 2001 From: David Waterman Date: Tue, 23 Jul 2024 15:01:46 +0100 Subject: [PATCH] Windows fix for `FormatCBFMini` (#742) If data were collected on a Windows system, then ":" may exist in the file path, not just the timestamp. --- newsfragments/742.bugfix | 2 ++ src/dxtbx/format/FormatCBFMini.py | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 newsfragments/742.bugfix diff --git a/newsfragments/742.bugfix b/newsfragments/742.bugfix new file mode 100644 index 000000000..dfcb2b06e --- /dev/null +++ b/newsfragments/742.bugfix @@ -0,0 +1,2 @@ +``FormatCBFMini``: when parsing header lines for a timestamp, avoid clashes with Windows paths. + diff --git a/src/dxtbx/format/FormatCBFMini.py b/src/dxtbx/format/FormatCBFMini.py index 8e24f1808..4947fecd3 100644 --- a/src/dxtbx/format/FormatCBFMini.py +++ b/src/dxtbx/format/FormatCBFMini.py @@ -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 @@ -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