maci docs
  • maci
  • WATCH
    • Quick Start
    • Full Training Series
  • DOCS
    • maci
      • language
        • v1.0.0
      • functions
        • maci.build
        • maci.load
        • maci.loadstr
        • maci.loadattrs
        • maci.loadraw
        • maci.loaddict
        • maci.loadstrdict
        • maci.dump
        • maci.dumpstr
        • maci.dumpraw
      • object
        • methods
          • lock_attr
          • unlock_attr
          • hard_lock_attr
          • map_attr
          • unmap_attr
          • load_attrs
          • get_attrs
          • get_locked_list
          • get_hard_locked_list
          • get_all_maps
          • get_parent_maps
          • get_child_maps
          • get_parent_map_chains
          • is_parent_map
          • is_child_map
      • errors
      • hints
    • json
      • functions
        • maci.jsonload
        • maci.jsonloadstr
        • maci.jsondump
        • maci.jsondumpstr
    • yaml
      • functions
        • maci.yamlload
        • maci.yamlloadstr
        • maci.yamlloadall
        • maci.yamldump
        • maci.yamldumpstr
        • maci.yamldumpall
    • toml
      • functions
        • maci.tomlload
        • maci.tomlloadstr
        • maci.tomldump
        • maci.tomldumpstr
    • ini
      • functions
        • maci.iniload
        • maci.inidump
        • maci.inibuildauto
        • maci.inibuildmanual
    • xml
      • functions
        • maci.xmlload
        • maci.xmlloadstr
        • maci.xmlloaddict
        • maci.xmlloadstrdict
        • maci.xmldump
        • maci.xmldumpstr
        • maci.xmldumpdict
        • maci.xmldumpstrdict
        • maci.xmlbuildmanual
        • maci._defuse_xml_stdlib
    • pickle
      • functions
        • maci.pickleloadbytes
        • maci.pickledumpbytes
    • tools
      • hash functions
        • maci.createhash
        • maci.createfilehash
        • maci.comparefilehash
      • format functions
        • maci.cleanformat
  • Updates
    • Changelog
      • v1.1.0
      • v1.0.0
Powered by GitBook
On this page
  1. DOCS
  2. ini
  3. functions

maci.inibuildauto

auto builds a configparser object from dict

Last updated 1 year ago

Auto builds a object from a dictionary with a correct section and key/value structure.

maci.inibuildauto ->

Example auto building ConfigParser data with sections and key/values

data_to_build = {'section1': {'key1': 1}, 'section2': {'key2': 2}}

data = maci.inibuildauto(data_to_build)

In this example, we created a simple dictionary representing sections with key names and their values and assigned the data to a variable, then passed the dict data as an argument to the inibuildauto function to build the ini data and assign the returned data to a variable.

dictionary structure

As shown in the example above, in order to auto-build the ini data for your object, your dictionary must follow a specific structure. The structure is as follows:

  • All top level key names in dict are sections

  • All values of each section must contain a dict with key/value pairs

Example structure unpacked

{ 
    'section1': {
        'key1': 'value1'
    },
    'section2': {
        'key2': 'value2'
    }
}

parameters & arguments

Describes all parameter functionality and accepted data types

data: dict[str, dict[str, Any]]

First and only required positional argument. Accepts dictionaries

Values can be anything, but when they are to a file and loaded back in, they will be loaded as a string type in their string representation (See )

Note: If your sub-value contains a NoneType, this function will auto-convert that to a string representation for you as the underlying library does not support None. More information on using ConfigParser data: Youtube Video Search: Documentation:

Use this parameter to pass in the data you want to build out the object.

This function uses the native configparser library shipped with the python standard library for its underlying functionality. For more information on the configparser library, visit:

ConfigParser
ConfigParser
ConfigParser
dumped
iniload
https://www.youtube.com/results?search_query=python+configparser
https://docs.python.org/3/library/configparser.html
ConfigParser
https://docs.python.org/3/library/configparser.html