From 8eff925ffa91d3d5e6a2840d3fd859782b623464 Mon Sep 17 00:00:00 2001 From: temitchell Date: Mon, 6 Dec 2004 04:45:17 +0000 Subject: [PATCH] - updates to datafile for guild scripts git-svn-id: svn://svn.code.sf.net/p/crossfire/code/trunk/maps@3002 282e977c-c81d-0410-88c4-b93c2d0d6712 --- python/CFDataFile.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/python/CFDataFile.py b/python/CFDataFile.py index c93d6fb00..c692d0770 100644 --- a/python/CFDataFile.py +++ b/python/CFDataFile.py @@ -121,12 +121,14 @@ class CFData: return 0 def exist(self, name): + '''checks if a record exists given the primary key as "name"''' if self.datadb.has_key(name): return 1 else: return 0 def get_record(self, name): + '''returns a small dictionary of the header and the record by "name"''' if self.exist(name): record = {} for header, item in zip(self.header,self.datadb[name]): @@ -135,8 +137,9 @@ class CFData: return record else: return 0 - + def put_record(self, record): + '''adds an line entry to the datafile''' name = record['#'] del record['#'] temp = [] @@ -145,6 +148,10 @@ class CFData: self.datadb[name]=temp self.datafile.putData(self.datadb) - - + def get_keys(self): + '''returns a sorted list of the primary keys (usually names) in the datafile''' + keys = self.datadb.keys() + keys.remove('#') + keys.sort() + return keys