FaceswapConfig

class lib.config.config.FaceswapConfig(config_file: str | None = None)

Bases: object

Config Items

Methods Summary

add_item(section, title, config_item)

Add a default item to a config section

add_section(title, info)

Add a default section to config file

save_config()

Update the ini file with the currently stored app values and save the config file.

set_defaults([helptext])

Override for plugin specific config defaults.

Methods Documentation

Parameters:

config_file (str | None)

add_item(section: str, title: str, config_item: ConfigItem) None

Add a default item to a config section

Parameters:
  • section (str) – The section of the config to add the item to

  • title (str) – The name of the config item

  • config_item (ConfigItem) – The default config item object to add to the config

Return type:

None

add_section(title: str, info: str) None

Add a default section to config file

Parameters:
  • title (str) – The title for the section

  • info (str) – The helptext for the section

Return type:

None

save_config() None

Update the ini file with the currently stored app values and save the config file.

Return type:

None

set_defaults(helptext: str = '') None

Override for plugin specific config defaults.

This method should always be overridden to add the help text for the global plugin group. If helptext is not provided, then it is assumed that there is no global section for this plugin group.

The default action will parse the child class’ module for ConfigItem objects and add them to this plugin group’s “global” section of sections.

The name of each config option will be the variable name found in the module.

It will then parse the child class’ module for subclasses of GlobalSection objects and add each of these sections to this plugin group’s sections, adding any ConfigItem within the GlobalSection to that sub-section.

The section name will be the name of the GlobalSection subclass, lowercased

Parameters:

helptext (str) – The help text to display for the plugin group

Raises:

ValueError – If the plugin group’s help text has not been provided

Return type:

None

add_item(section: str, title: str, config_item: ConfigItem) None

Add a default item to a config section

Parameters:
  • section (str) – The section of the config to add the item to

  • title (str) – The name of the config item

  • config_item (ConfigItem) – The default config item object to add to the config

Return type:

None

add_section(title: str, info: str) None

Add a default section to config file

Parameters:
  • title (str) – The title for the section

  • info (str) – The helptext for the section

Return type:

None

save_config() None

Update the ini file with the currently stored app values and save the config file.

Return type:

None

sections: dict[str, ConfigSection]

The Faceswap config sections and options

Type:

dict[str, ConfigSection]

set_defaults(helptext: str = '') None

Override for plugin specific config defaults.

This method should always be overridden to add the help text for the global plugin group. If helptext is not provided, then it is assumed that there is no global section for this plugin group.

The default action will parse the child class’ module for ConfigItem objects and add them to this plugin group’s “global” section of sections.

The name of each config option will be the variable name found in the module.

It will then parse the child class’ module for subclasses of GlobalSection objects and add each of these sections to this plugin group’s sections, adding any ConfigItem within the GlobalSection to that sub-section.

The section name will be the name of the GlobalSection subclass, lowercased

Parameters:

helptext (str) – The help text to display for the plugin group

Raises:

ValueError – If the plugin group’s help text has not been provided

Return type:

None