WrightTools.kit.INI

class WrightTools.kit.INI(filepath)[source]

Bases: object

Handle communication with an INI file.

__init__(filepath)[source]

Create an INI handler object.

Parameters

filepath (path-like) – Filepath.

add_section(section)[source]

Add section.

Parameters

section (string) – Section to add.

clear()[source]

Remove all contents from file. Use with extreme caution.

Warning

This is a destructive action.

dictionary

Get a python dictionary of contents.

get_options(section) → list[source]

List the options in a section.

Parameters

section (string) – The section to investigate.

Returns

The options within the given section.

Return type

list of strings

has_option(section, option) → bool[source]

Test if file has option.

Parameters
  • section (string) – Section.

  • option (string) – Option.

Returns

Return type

boolean

has_section(section) → bool[source]

Test if file has section.

Parameters

section (string) – Section.

Returns

Return type

boolean

read(section, option)[source]

Read from file.

Parameters
  • section (string) – Section.

  • option (string) – Option.

Returns

Value.

Return type

string

sections

List of sections.

write(section, option, value)[source]

Write to file.

Parameters
  • section (string) – Section.

  • option (string) – Option.

  • value (string) – Value.