2 Flat ASCII Database to implement VERY simple config files.
9 error = "fladc.error" # Too many records
12 class Flad_Conf(dict):
14 FLAD config is just FLAD Database with exactly ONE record.
15 Flad_Conf objects are just UserDicts.
17 def __init__(self, must_keys = None, other_keys = None):
20 self.must_keys = must_keys
21 self.other_keys = other_keys
26 db = fladm.Flad_WithMustKeys(check_record, self.must_keys, self.other_keys)
33 def load_file(self, f):
38 raise error, "incorrect number of records in config file `%s'; expected 1, got %d" % (str(f), len(db))
43 def load_from_file(self, f):
48 raise error, "incorrect number of records in config file `%s'; expected 1, got %d" % (str(f), len(db))
53 def store_to_file(self, f):
59 def check_record(data, record): # Only allow append 1 record
63 def load_file(f, must_keys = None, other_keys = None):
65 Create a database object and load it from file
68 db = Flad_Conf(must_keys, other_keys)
74 def load_from_file(f, must_keys = None, other_keys = None):
76 Create a database object and load it from file
79 db = Flad_Conf(must_keys, other_keys)