2 Flat ASCII Database to implement VERY simple config files.
4 Written by Broytman. Copyright (C) 1997-2005 PhiloSoft Design
11 error = "fladc.error" # Too many records
14 class Flad_Conf(dict):
16 FLAD config is just FLAD Database with exactly ONE record.
17 Flad_Conf objects are just UserDicts.
19 def __init__(self, must_keys = None, other_keys = None):
22 self.must_keys = must_keys
23 self.other_keys = other_keys
28 db = fladm.Flad_WithMustKeys(check_record, self.must_keys, self.other_keys)
35 def load_file(self, f):
40 raise error, "incorrect number of records in config file `%s'; expected 1, got %d" % (str(f), len(db))
45 def load_from_file(self, f):
50 raise error, "incorrect number of records in config file `%s'; expected 1, got %d" % (str(f), len(db))
55 def store_to_file(self, f):
61 def check_record(data, record): # Only allow append 1 record
65 def load_file(f, must_keys = None, other_keys = None):
67 Create a database object and load it from file
70 db = Flad_Conf(must_keys, other_keys)
76 def load_from_file(f, must_keys = None, other_keys = None):
78 Create a database object and load it from file
81 db = Flad_Conf(must_keys, other_keys)