Skip to main content

A simple class for converting a *.cfg file to a Python Dictionary

Project description

-- ConfigToDictionary
Convert a python config file of to a python dictionary

-- Example
Return the information in `info.cfg` as a `JSON` response from a `Flask` server:

info.cfg
----------
[info]
name = risk
version = 1
description = A simple game of chance. Risk 1000 Satoshis, win 2000, or lose them all.
project = https://github.com/joelklabo/risk

[risk]
price = 1000
description = 49/100 chance you will double your satoshis
```

server.py
----------
from flask import Flask
from flask.ext.responses import json_response
from cfgtodict import ConfigToDictionary

app = Flask(__name__)

@app.route('/info')
def info():
about = ConfigToDictionary('info.cfg').dict()
return json_response(about)
```

JSON response
----------
{
"info": {
"description": "A simple game of chance. Risk 1000 Satoshis, win 2000, or lose them all.",
"name": "risk",
"project": "https://github.com/joelklabo/risk",
"version": "1"
},
"risk": {
"description": "49/100 chance you will double your satoshis",
"price": "1000"
}
}
```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cfgtodict-0.1.2.tar.gz (1.1 kB view details)

Uploaded Source

File details

Details for the file cfgtodict-0.1.2.tar.gz.

File metadata

  • Download URL: cfgtodict-0.1.2.tar.gz
  • Upload date:
  • Size: 1.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for cfgtodict-0.1.2.tar.gz
Algorithm Hash digest
SHA256 dfc0a42b77f8cf89861c83db44383f744ac586d4fdf7389f27065b6f2175b19e
MD5 93e937f9824286019188523f22db3efd
BLAKE2b-256 2e917fe4fdfbe85b3118b2a15b48508fb6eded67632f2e4b2639269d8104aab7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page