Trees | Indices | Help |
---|
|
The resolver class implements a persistent two-way mapping, typically between strings.
Persistence is ensured by using a YAML file to store the mapping
Resolver maps both keys to values and values to keys.
If asked to map an unknown key or value, the code treats this as a value and auto-generates a key using a hash function.
EXAMPLE OF USE:
>>> r = Resolver("parrot.yml") >>> r.get('parrot','is dead') 'is dead' >>> r['met'] = 'its maker' >>> r['met'] 'its maker' >>> r.save() >>> r2 = Resolver("parrot.yml") >>> r2['its maker'] 'met'
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
|
|||
Inherited from |
|
Resolve using mapping stored in file named fn NOTE: the file's directory must be read-write Resolver will save temporary files to this directory
|
Load contents from file storage. Silently returns if file is not found / inaccessible |
Save mapping to a YAML file. EXAMPLE: >>> r = Resolver('spam') >>> r['ham']='spam' >>> r['banana']='weapon' >>> r.save() ALGORITHM: File is first saved to a temporary filename, then the old file is removed and the new file renamed (a.k.a. 'safe save') |
Find key/value associated with key. If not found, return default |
Find key/value associated with key. If not found:
|
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu Jan 4 16:46:17 2018 | http://epydoc.sourceforge.net |