A utility module to convert a plain text key-value pair based data to python
dictionary. It is useful to retrieve plain text based configuration options
for any python application.
Copyrights: K Raghu Prasad [Prangya Technologies Pvt. Ltd.]
License: GNU Library General Public License (Version 2).
Co-Authors: Ashish Doshi
$Revision: 0.1 $
$Date: 2003/01/01 08:34:09 $
$Author: admin $
||Class to handle conversion of string based name to its respective|
value. The name and its value is stored in a file which is passed on
as a parameter to the constructor. Null cannot occupy the position of
key. White space characters are stripped from either ends of key
and value. All lines starting with `#' is ignored.
A sample relations file (ignore '|'):
|# <- file begins.
|# <- file ends.
A sample script using class Relations and associated methods (ignore '|'):
|# <- script begins.
|from prangya.relations import *
| rel = Relations('/etc/passwd')
|except IOError, mesg:
| print mesg.error
| print 'Details for "root" are:'
| print rel._('root')
| print 'List of system users are:'
| print rel.keys()
| print 'List of details for each user are:'
| print rel.values()
|# <- script ends.
||Methods defined here:|
- _(self, key)
- The member function to determine the value of a particular key.
If the key does not exist, an exception(KeyError) is raised.
- __init__(self, filename)
- Constructor which takes a file as parameter. The contents of the file
are key value pairs separated by colon(:).
- The member function to return all keys currently held by the instance
of this class. The ordering of the keys are random.
- The member function to return values for all the keys currently held
by the instance of this class. The ordering of the values are random.
Data and non-method functions defined here:
- __doc__ = '\n Class to handle conversion of string base...print rel.values()\n |# <- script ends.\n '
- __module__ = 'prangya.relations'
||__file__ = '/usr/lib/python2.2/site-packages/prangya/relations.pyc'|
__name__ = 'prangya.relations'
__version__ = '0.1'