pwtools.arrayio._read_header_config

pwtools.arrayio._read_header_config(fh, header_maxlines=20, header_comment='#')[source]

Read a ini-style file from the header of a text file. Return a ConfigParser object.

Parameters:
  • fh (file handle, readable)

  • header_maxlines (max lines to read down from top of the file)

  • header_comment (comment sign w/ which the header must be prefixed)

Return type:

ConfigParser object

Examples

>>> !cat foo.txt
# [array]
# shape = 3
# axis = -1
1
2
3
>>> _get_header_config('foo.txt')
<pwtools.common.ConfigParser instance at 0x2c52320>