From 9a23daf7b3ca3f5aab8d0c257e387b6e2d735c24 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 24 Sep 2024 10:44:06 +0500 Subject: [PATCH] stream - add support of crlf files --- src/ifcopenshell-python/ifcopenshell/stream.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/stream.py b/src/ifcopenshell-python/ifcopenshell/stream.py index 46f593ad50..141598b56f 100644 --- a/src/ifcopenshell-python/ifcopenshell/stream.py +++ b/src/ifcopenshell-python/ifcopenshell/stream.py @@ -157,6 +157,7 @@ try: exclude = set() offset = 0 + newline_character = len(os.linesep) for line in self.file: line = line.strip() if line.startswith("#"): @@ -165,7 +166,7 @@ try: ifc_class = ifc_class.strip() if ifc_class in exclude: - offset += len(line) + 1 # +1 for the newline character + offset += len(line) + newline_character continue for reference_id in self.reference_pattern.findall(line[1:]): @@ -180,7 +181,7 @@ try: for ifc_class in exclude_classes: declaration = self.ifc_schema.declaration_by_name(ifc_class) exclude.update([st.name().upper() for st in ifcopenshell.util.schema.get_subtypes(declaration)]) - offset += len(line) + 1 # +1 for the newline character + offset += len(line) + newline_character self.preprocess_schema()