You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

pycnf

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pycnf

Implements the JSON, INI, YAML and TOML parser for Python setting and writing of configuration file.

0.0.8
pipPyPI
Maintainers
1

pycnf Python package

The Python package 'pycnf' implements the json, configparser, yaml and toml parser for python setting and writing of configuration file.

Introduction

The configuration file are necessary for many projects that will help us to manage and set project environment variables easily.

Configuration files, from INI/XML/JSON/YAML to TOML, readability and maneuverability have been improved too much in the past few years, and there are serveral parsers be created in Python and other programming language. That have made us becomes more efficient, but, we need to remember the different functions for different format configuration file that sometimes we only just want to read it and regardless of that format. So, using single function to read or/and write most of configuration file are good way to reduce memory burden.

pycnf have done some work to relax us on configuration files that can be used to parse and generate JSON/INI/YAML/TOML format configuration file.

Configuration file format

JSON

{   "default":{
        "debug":"{{debug}} {{debug2}}"
    },
    "comments":{
        "version":"0.2.0",
        "test_parse":"{{key:test_parse}} {{key:test_parse2}}",
        "test_parse2":"@>@ str_replace('{{key:test_parse}}', '2', '00')@<@ {{key:test_parse2}} {{debug2}}",
        "test_parse3":"{{key:test_parse}}",
        "test_parse4":"@>@ str_replace('{{key:test_parse2}}', '2', '00')@<@ @>@ str_replace('{{key:test_parse}}', '2', '00')@<@ {{key:test_parse2}} {{debug2}}"
    }
}

More infomation and example of JSON can be founded in json.org, JSON Example and JSON-wikipedia. {{key:key:value}}/{{key}} can be parsed by parse.extra using extra.list and other.config parameters. @>@ str_replace("123", "2", "1")@<@ can be parsed by parse.extra setting parameter rcmd.parse to TRUE. Example of that can be founded in this document tail.

INI

[default]
debug = {{debug}} {{debug2}}

[comments]
version = 0.2.0
test_parse = {{key:test_parse}} {{key:test_parse2}}
test_parse2 = @>@ str_replace('{{key:test_parse}}', '2', '00')@<@ {{key:test_parse2}} {{debug2}}
test_parse3 = {{key:test_parse}}
test_parse4 = @>@ str_replace('{{key:test_parse2}}', '2', '00')@<@ @>@ str_replace('{{key:test_parse}}', '2', '00')@<@ {{key:test_parse2}} {{debug2}}

More infomation and example of INI can be founded in INI-wikipedia.

YAML

default:
  debug: '{{debug}} {{debug2}}'
comments:
  version: 0.2.0
  test_parse: '{{key:test_parse}} {{key:test_parse2}}'
  test_parse2: '@>@ str_replace(''{{key:test_parse}}'', ''2'', ''00'')@<@ {{key:test_parse2}}
    {{debug2}}'
  test_parse3: '{{key:test_parse}}'
  test_parse4: '@>@ str_replace(''{{key:test_parse2}}'', ''2'', ''00'')@<@ @>@ str_replace(''{{key:test_parse}}'',
    ''2'', ''00'')@<@ {{key:test_parse2}} {{debug2}}'

More infomation and example of YAML can be founded in yaml.org and YAML-wikipedia.

TOML

title = "TOML Example"

[default]
debug = true

[comments]
version = "0.1.0"

More infomation and example of TOML can be founded in and toml-lang/toml and TOML-wikipedia.

Installation

pip

#You can install this package directly from PYPI by running:
pip install pycnf

Keywords

configuration setuptools development

FAQs

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.