tlpipe.kiyopy.parse_ini

This parser is my system for reading input files for large programs. The idea is that the only argument for the program should always be the input file and all the parameters are read from that file. The input file will have plain python syntax. I’ve found this to have the best flexibility, avoiding the need to have many versions of the same code. However, because any python statements are executed when the input file is read, this system is not appropriate if security is an issue (it’s an arbitrary code execution security hole).

This is purposely written as a set of functions rather than a class. I can think of no reason that you would want the parser to stick around after being called and the output dictionaries are pretty self contained.

Revision History:

  • KM Aug. ‘10

    • Wrote initial code (fileparser and dictparser).
    • Later converted fileparser to just parse, which is an interface for both files and dicts.
  • KM Oct. ‘10

    • Added write_params
  • KM Mar. ‘11

    • Changed checking argument to feedback and type_check.

Functions

parse(ini_data, params[, return_undeclared, ...]) Parses a python file or dictionary to get parameters.
parse_dict(dict_to_parse, params[, ...]) Same as parse_ini.parse except parameters read from only dictionary.
write_params(params, file_name[, prefix, mode]) Write a parameter dictionary to file.