提交 5ad0642b authored 作者: Frederic Bastien's avatar Frederic Bastien

in class DB moved some stuff to a new fct add_tags(name,*tags). This allow to…

in class DB moved some stuff to a new fct add_tags(name,*tags). This allow to add tag to an optimizer after it have bean registered.
上级 2c6efaab
...@@ -35,6 +35,13 @@ class DB(object): ...@@ -35,6 +35,13 @@ class DB(object):
raise ValueError('The name of the object cannot be an existing tag or the name of another existing object.', obj, name) raise ValueError('The name of the object cannot be an existing tag or the name of another existing object.', obj, name)
self.__db__[name] = set([obj]) self.__db__[name] = set([obj])
self._names.add(name) self._names.add(name)
self.add_tags(name, *tags)
def add_tags(self, name, *tags):
obj = self.__db__[name]
assert len(obj)==1
obj = obj.copy().pop()
for tag in tags: for tag in tags:
if tag in self._names: if tag in self._names:
raise ValueError('The tag of the object collides with a name.', obj, tag) raise ValueError('The tag of the object collides with a name.', obj, tag)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论