X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=m_lib%2Fflad%2Ffladm.py;h=6143122e057a3d5a6113324c1962bfec46e70e4b;hb=0e5f895d697a65cbb0fdfc9fd2ba315225b491d2;hp=9e835bca2b4eb25c326dcd5e7abbacb02c186193;hpb=13a21366e5dbeb344656cbfd00432be176ae5cdb;p=m_lib.git diff --git a/m_lib/flad/fladm.py b/m_lib/flad/fladm.py index 9e835bc..6143122 100644 --- a/m_lib/flad/fladm.py +++ b/m_lib/flad/fladm.py @@ -1,11 +1,9 @@ """ Flat ASCII Database with "must" keys - - Written by Broytman. Copyright (C) 1997-2005 PhiloSoft Design """ -from flad import Flad, def_keysep +from m_lib.flad.flad import Flad, def_keysep class Flad_WithMustKeys(Flad): @@ -44,12 +42,12 @@ class Flad_WithMustKeys(Flad): if self.other_keys: for key in self.other_keys: - if copy_rec.has_key(key): + if key in copy_rec: outfile.write(key + def_keysep + copy_rec[key] + '\n') del copy_rec[key] if copy_rec: - for key in copy_rec.keys(): + for key in list(copy_rec.keys()): outfile.write(key + def_keysep + copy_rec[key] + '\n') del copy_rec[key] @@ -73,11 +71,11 @@ def check_record(data, record): if must_keys and (key in must_keys): del copy_must[copy_must.index(key)] # Remove the key from copied list elif (must_keys and (key not in must_keys) and (other_keys and (key not in other_keys))) or (other_keys and (key not in other_keys)): - raise KeyError, "field key \"" + key + "\" is not in list of allowed keys" + raise KeyError("field key \"" + key + "\" is not in list of allowed keys") if copy_must: # If there is at least one key - it is an error: # not all "must" keys are in record - raise KeyError, "not all \"must\" keys are in record; keys: " + str(copy_must) + raise KeyError("not all \"must\" keys are in record; keys: " + str(copy_must)) return 1