iniparser

Parse a single ini file, or a directory of ini files.

class pyskool.iniparser.IniParser(path, verbose=True)

Parses one or more ini files.

Parameters:
  • path – An ini file, or a directory to scan for ini files.
  • verbose – Whether to print status information while reading files.
get_config(pattern)

Return a dictionary of keys and values from every section whose name matches pattern.

parse_section(name, parse_numbers=True, num_elements=None, split=True, separator=', ')

Extract the elements from every line in a section. The return value is a list of lists of elements from each line (if split is True), or a list of the lines. If the named section does not exist, an empty list is returned.

Parameters:
  • name – The name of the section.
  • parse_numbers – If True, any numeric element is converted to a number; otherwise it is left as a string.
  • num_elements – The minimum number of elements to return for each line in the section. If any line has fewer elements than this, the list of elements is padded out with None instances.
  • split – If True, each line is split on commas; otherwise, the line is returned whole.
  • separator – The character sequence that separates the elements in a line.

Previous topic

graphics

Next topic

input