|
15 | 15 | from io import BytesIO |
16 | 16 | from pathlib import Path |
17 | 17 | from typing import TYPE_CHECKING, Any, cast |
| 18 | +from xml.etree import ElementTree as ET |
18 | 19 |
|
19 | 20 | import numpy as np |
20 | | -from lxml import etree as ET |
21 | 21 | from monty.dev import requires |
22 | 22 | from monty.io import reverse_readfile, zopen |
23 | 23 | from monty.json import MSONable, jsanitize |
@@ -331,10 +331,10 @@ def __init__( |
331 | 331 | self.separate_spins = separate_spins |
332 | 332 | self.exception_on_bad_xml = exception_on_bad_xml |
333 | 333 |
|
334 | | - with zopen(filename, mode="rb") as file: |
| 334 | + with zopen(filename, mode="rt", encoding="utf-8") as file: |
335 | 335 | if ionic_step_skip or ionic_step_offset: |
336 | 336 | # Remove parts of the xml file and parse the string |
337 | | - content: str = file.read().decode("utf-8") |
| 337 | + content: str = file.read() |
338 | 338 | steps: list[str] = content.split("<calculation>") |
339 | 339 |
|
340 | 340 | # The text before the first <calculation> is the preamble! |
@@ -408,7 +408,7 @@ def _parse( |
408 | 408 | # whether they are nested within another block. This is why we |
409 | 409 | # must read both start and end tags and have flags to tell us |
410 | 410 | # when we have entered or left a block. (2024-01-26) |
411 | | - for event, elem in ET.iterparse(stream, events=["start", "end"], remove_blank_text=True): |
| 411 | + for event, elem in ET.iterparse(stream, events=["start", "end"]): |
412 | 412 | tag = elem.tag |
413 | 413 | if event == "start": |
414 | 414 | # The start event tells us when we have entered blocks |
@@ -1799,13 +1799,13 @@ def __init__( |
1799 | 1799 | self.occu_tol = occu_tol |
1800 | 1800 | self.separate_spins = separate_spins |
1801 | 1801 |
|
1802 | | - with zopen(filename, mode="rb") as file: |
| 1802 | + with zopen(filename, mode="rt", encoding="utf-8") as file: |
1803 | 1803 | self.efermi = None |
1804 | 1804 | parsed_header = False |
1805 | 1805 | in_kpoints_opt = False |
1806 | 1806 | self.eigenvalues = self.projected_eigenvalues = None |
1807 | 1807 | self.kpoints_opt_props = None |
1808 | | - for event, elem in ET.iterparse(file, events=["start", "end"], remove_blank_text=True): |
| 1808 | + for event, elem in ET.iterparse(file, events=["start", "end"]): |
1809 | 1809 | tag = elem.tag |
1810 | 1810 | if event == "start": |
1811 | 1811 | # The start event tells us when we have entered blocks |
|
0 commit comments