Socket
Socket
Sign inDemoInstall

configparser-list

Package Overview
Dependencies
3
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    configparser-list

Extends ConfigParser to support lists


Maintainers
1

Readme

Build Status codecov

configparser-list

Extends ConfigParser to support lists (getlist)

Install

pip install configparser-list

Tests

To run the tests:

python -m unittest

Examples

Example 1 uses dict

from ConfigParserList import ConfigParser


def list_from_dict():
    """
    This example sets the configuration from a dict and then fetchs a list
    :return:
    """
    str_list = ['A', "B", "C"]
    int_list = [1, 2, 3]
    d = {'SEC': {
        'int': 10,
        'float': 1.0,
        'liststr': str_list,
        'listint': int_list}
    }
    conf = ConfigParser()
    conf.read_dict(d)
    alpha = conf.getlist('SEC', 'liststr')
    ints = conf.getlistint('SEC', 'listint')
    print("list from config (dict): ")
    print(f"Alpha {alpha} is of type {type(alpha)}")
    print(f"Ints {ints} is of type {type(ints)}")

Example 2 uses str

from ConfigParserList import ConfigParser

def list_from_string():
    """
    This example sets the configuration from a string and then fetchs a list
    :return:
    """
    conf_str = """
    [SEC]
    int=10,
    float=1.0,
    liststr=A, B, C
    listint=1, 2, 3
    """
    conf = ConfigParser()
    conf.read_string(conf_str)
    alpha = conf.getlist('SEC', 'liststr')
    ints = conf.getlistint('SEC', 'listint')
    print("list from config (string): ")
    print(f"Alpha {alpha} is of type {type(alpha)}")
    print(f"Ints {ints} is of type {type(ints)}")

Keywords

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc