2000-11-27 18:28:20 +00:00
|
|
|
#This file is distributed under the terms of the GNU General Public license.
|
|
|
|
|
#Copyright (C) 1999 Aloril (See the file COPYING for details).
|
|
|
|
|
|
|
|
|
|
class Knowledge:
|
2004-11-19 01:58:28 +00:00
|
|
|
def __init__(self):
|
|
|
|
|
self.place={}
|
|
|
|
|
self.location={}
|
|
|
|
|
self.goal={}
|
|
|
|
|
self.importance={}
|
2000-11-27 18:28:20 +00:00
|
|
|
def add(self, what, key, value):
|
2004-10-11 01:04:27 +00:00
|
|
|
if not hasattr(self, what):
|
|
|
|
|
setattr(self, what, {})
|
2000-11-27 18:28:20 +00:00
|
|
|
d=getattr(self,what)
|
|
|
|
|
d[key]=value
|
2005-07-03 23:08:38 +00:00
|
|
|
def remove(self, what, key):
|
|
|
|
|
if not hasattr(self, what):
|
|
|
|
|
return
|
|
|
|
|
d=getattr(self,what)
|
|
|
|
|
if d.has_key(key):
|
|
|
|
|
del d[key]
|
|
|
|
|
if len(d)==0:
|
|
|
|
|
delattr(self,what)
|
2000-11-27 18:28:20 +00:00
|
|
|
def __str__(self):
|
|
|
|
|
s="<know: "
|
|
|
|
|
s=s+"place: "+str(self.place)+"\n"
|
|
|
|
|
s=s+"location: "+str(self.location)+"\n"
|
|
|
|
|
s=s+"goal: "+str(self.goal)+"\n"
|
|
|
|
|
s=s+"importance: "+str(self.importance)+"\n"
|
|
|
|
|
return s+">\n"
|
|
|
|
|
|