Skip to content

Commit

Permalink
docs: Add docstring to load() in packed.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kmnhan committed Apr 3, 2024
1 parent 6670245 commit 143f127
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion igor2/packed.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@


def load(filename, strict=True, ignore_unknown=True, initial_byte_order=None):
"""Load a packed experiment file.
Parameters
----------
filename : str or file-like object
The path to the file or a file-like object representing the packed
experiment file.
strict : bool, optional
This parameter is ignored. Defaults to True.
ignore_unknown : bool, optional
If True, ignore unknown record types. Defaults to True.
initial_byte_order : str or None, optional
The initial byte order to use for unpacking. Must be one of '>', '=',
'<'. If None, '=' is used. Defaults to None.
Returns
-------
records : list of Record
The records in the packed experiment file.
filesystem : dict
The filesystem structure of the packed experiment file.
"""
logger.debug('loading a packed experiment file from {}'.format(filename))
records = []
if hasattr(filename, 'read'):
Expand Down Expand Up @@ -81,7 +103,8 @@ def load(filename, strict=True, ignore_unknown=True, initial_byte_order=None):
data = bytes(f.read(header['numDataBytes']))
if len(data) < header['numDataBytes']:
raise ValueError(
('not enough data for the next record ({} < {})'
('not enough data for the next record ({} < {}), '
'try loading with a different initial byte order'
).format(len(b), header['numDataBytes']))
record_type = _RECORD_TYPE.get(
header['recordType'] & PACKEDRECTYPE_MASK, _UnknownRecord)
Expand Down

0 comments on commit 143f127

Please sign in to comment.