-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
def __init__(self, fn: str | Path | Iterable[str], cast_values: bool = False):
"""Create a CifFile object from a filename or buffer.
On construction, the entire file is parsed into key-value pairs and data loops.
Comment lines are ignored.
Parameters
----------
fn : str | Path | Iterable[str]
File path or buffer containing CIF data
cast_values : bool, optional
Whether to convert string numerics to integers and float.
Default value = ``False``
"""
self._fn = fn
self._pairs = {}
self._loops = []
self._cpat = {k: re.compile(pattern) for (k, pattern) in self.PATTERNS.items()}
self._cast_values = cast_values
if isinstance(fn, (str, Path)):
with open(fn) as file:
self._parse(peekable(file))
else:
# Assume it's a buffer/iterable
self._parse(peekable(fn))
something like this would enable users to load files from places like s3 and then still be able to make sure of this parser without having to save a tmp file to disk.
Metadata
Metadata
Assignees
Labels
No labels