Skip to content

Commit

Permalink
De-exposing parse_metadata, linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Attolight-NTappy committed Jul 4, 2024
1 parent 4f437e7 commit 9927de6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions rsciio/digitalsurf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ._api import file_reader, file_writer, parse_metadata
from ._api import file_reader, file_writer

__all__ = ["file_reader", "file_writer", "parse_metadata"]
__all__ = ["file_reader", "file_writer"]


def __dir__():
Expand Down
25 changes: 14 additions & 11 deletions rsciio/digitalsurf/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,27 @@
_logger = logging.getLogger(__name__)


def parse_metadata(cmt: str, prefix: str = '$', delimiter: str = '=') -> dict:
"""Parse metadata from the comment field of a digitalsurf file, or any other
def parse_metadata(cmt : str, prefix : str = '$', delimiter : str = '=') -> dict:
"""
Parse metadata from the comment field of a digitalsurf file, or any other
str in similar formatting. Return it as a hyperspy-compatible nested dict.
Parameters
----------
cmt: str
str containing contents of a digitalsurf file comment field
prefix: str, default = '$'
prefix character that must start each line, otherwise line is ignored.
'$' for digitalsurf files, typically '' when parsing from text files
delimiter: string, default = '='
Character that delimit key-value pairs in digitalsurf comments.
Usually '='
cmt : str
Str containing contents of a digitalsurf file "comment" field.
prefix : str, default = '$'
Prefix character, must be present at the start of each line.
Otherwise, the line is ignored. '$' for digitalsurf files,
typically '' when parsing from text files.
delimiter : string, default = '='
Character that delimit key-value pairs in digitalsurf comment.
Usually, '=' is used.
Returns
-------
dict_md: nested dictionnary.
dict_md : dict
Nested dictionnary containing comment contents.
"""
# dict_ms is created as an empty dictionnary
Expand Down

0 comments on commit 9927de6

Please sign in to comment.