Skip to content

Instantly share code, notes, and snippets.

@zodman
Created August 9, 2009 18:42
Show Gist options
  • Save zodman/164865 to your computer and use it in GitHub Desktop.
Save zodman/164865 to your computer and use it in GitHub Desktop.
In [1]: file = """
...: package_name = openssl
...:
...: summary = A general purpose cryptography library with TLS implementation # one line
...:
...: description = \"\"\"The OpenSSL toolkit provides support for secure communications between
...: machines. OpenSSL includes a certificate management tool and shared
...: libraries which provide various cryptographic algorithms and
...: protocols.\"\"\" # multiline
...:
...: URL = http://www.openssl.org/
...:
...: licensing= OpenSSL
...:
...: sets = TBD
...:
...: tracks = koji 4.fc11
...:
...: [SubPackage] # package generate by openssl
...: package_name = openssl-scripts
...: summary= Perl scripts provided with OpenSSL
...:
...: description =\"\"\"OpenSSL is a toolkit for supporting cryptography. The openssl-scripts
...: package provides Perl scripts for converting certificates and keys
...: from other formats to the formats used by the OpenSSL toolkit.\"\"\"
...: """.splitlines()
In [2]: from configobj import ConfigObj
In [3]: cfg = ConfigObj(file)
In [4]: cfg
Out[4]: ConfigObj({'package_name': 'openssl', 'summary': 'A general purpose cryptography library with TLS implementation', 'description': 'The OpenSSL toolkit provides support for secure communications between\nmachines. OpenSSL includes a certificate management tool and shared\nlibraries which provide various cryptographic algorithms and\nprotocols.', 'URL': 'http://www.openssl.org/', 'licensing': 'OpenSSL', 'sets': 'TBD', 'tracks': 'koji 4.fc11', 'SubPackage': {'package_name': 'openssl-scripts', 'summary': 'Perl scripts provided with OpenSSL', 'description': 'OpenSSL is a toolkit for supporting cryptography. The openssl-scripts\npackage provides Perl scripts for converting certificates and keys\nfrom other formats to the formats used by the OpenSSL toolkit.'}})
In [6]: cfg["SubPackage"]
Out[6]: {'package_name': 'openssl-scripts', 'summary': 'Perl scripts provided with OpenSSL', 'description': 'OpenSSL is a toolkit for supporting cryptography. The openssl-scripts\npackage provides Perl scripts for converting certificates and keys\nfrom other formats to the formats used by the OpenSSL toolkit.'}
In [7]: cfg["package_name"]
Out[7]: 'openssl'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment