sparc.sparc_parsers.utils module

sparc.sparc_parsers.utils.bisect_and_strip(text, delimiter)[source]

split string in 2 at first occurence of a character and remove whitespace useful for separating comments from data, keys from values, etc.

sparc.sparc_parsers.utils.get_label(fileobj, ext)[source]

Return the label of file by stripping the extension (e.g. .ion)

sparc.sparc_parsers.utils.make_reverse_mapping(mapping)[source]

Given a list of mapping, get its reverse mapping

For example: mapping = [0, 2, 3, 1, 5, 4] reverse = [0, 3, 1, 2, 5, 4]

sparc.sparc_parsers.utils.read_block_input(block, validator=None)[source]

Read blocks of inputs from ion or inpt file and convert with validator

the following inputs are accepted: 1) single line input: KEY: VALUE 2) multiline input: KEY: VALUE1

VALUE2 –> (concanate the values)
  1. multiline input w/ blank first line: KEY:

VALUE1 VALUE2 –> (append the values)

sparc.sparc_parsers.utils.strip_comments(rawtext, symbol='#')[source]

Strip comments from the text, including trailing comments