- updates to datafile for guild scripts
git-svn-id: svn://svn.code.sf.net/p/crossfire/code/trunk/maps@3002 282e977c-c81d-0410-88c4-b93c2d0d6712master
parent
7cf2013a82
commit
8eff925ffa
|
@ -121,12 +121,14 @@ class CFData:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def exist(self, name):
|
def exist(self, name):
|
||||||
|
'''checks if a record exists given the primary key as "name"'''
|
||||||
if self.datadb.has_key(name):
|
if self.datadb.has_key(name):
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def get_record(self, name):
|
def get_record(self, name):
|
||||||
|
'''returns a small dictionary of the header and the record by "name"'''
|
||||||
if self.exist(name):
|
if self.exist(name):
|
||||||
record = {}
|
record = {}
|
||||||
for header, item in zip(self.header,self.datadb[name]):
|
for header, item in zip(self.header,self.datadb[name]):
|
||||||
|
@ -135,8 +137,9 @@ class CFData:
|
||||||
return record
|
return record
|
||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def put_record(self, record):
|
def put_record(self, record):
|
||||||
|
'''adds an line entry to the datafile'''
|
||||||
name = record['#']
|
name = record['#']
|
||||||
del record['#']
|
del record['#']
|
||||||
temp = []
|
temp = []
|
||||||
|
@ -145,6 +148,10 @@ class CFData:
|
||||||
self.datadb[name]=temp
|
self.datadb[name]=temp
|
||||||
self.datafile.putData(self.datadb)
|
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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue