[Pli-devel] pli-devel/pli/tags generic.py, 1.15, 1.16 tag.py, 1.14, 1.15
Status: Pre-Alpha
Brought to you by:
alex_nanou
|
From: Alex A. N. <ale...@us...> - 2008-03-07 11:34:34
|
Update of /cvsroot/pli/pli-devel/pli/tags In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2986/pli/tags Modified Files: generic.py tag.py Log Message: Index: tag.py =================================================================== RCS file: /cvsroot/pli/pli-devel/pli/tags/tag.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tag.py 7 Mar 2008 10:30:34 -0000 1.14 --- tag.py 7 Mar 2008 11:34:38 -0000 1.15 *************** *** 2,6 **** __version__ = '''0.0.01''' ! __sub_version__ = '''20080307132444''' __copyright__ = '''(c) Alex A. Naanou 2007''' --- 2,6 ---- __version__ = '''0.0.01''' ! __sub_version__ = '''20080307143129''' __copyright__ = '''(c) Alex A. Naanou 2007''' *************** *** 109,113 **** 'addtags', 'tag', ! 'untag' 'tags', 'relatedtags', --- 109,113 ---- 'addtags', 'tag', ! 'untag', 'tags', 'relatedtags', *************** *** 118,140 **** # NOTE: this is not intended for direct use... proxyutils.proxymethod('_rawtag', '__tag_engine__', '_tag', ! doc='NOTE: this was not intended for direct use!\n', explicit_self=True) - # XXX add store management inteface... - ## def isconsistent(self): - ## ''' - ## ''' - ## pass - ## def fixgaps(self): - ## ''' - ## ''' - ## pass #--------------------------------------------TagSetWithTagChainsMixin--- ! # XXX add chain formatting functions/methods... ! # .getchain(*tags) class TagSetTagChainMixin(object): ''' NOTE: this must be mixed with a valid tagset. --- 118,151 ---- # NOTE: this is not intended for direct use... proxyutils.proxymethod('_rawtag', '__tag_engine__', '_tag', ! doc='NOTE: this was not intended for direct use!', ! explicit_self=True) ! ! # store management inteface... ! proxyutils.proxymethod('isconsistent', '__tag_engine__', 'istagsconsistent', ! doc='check for tag consistency', ! explicit_self=True) ! proxyutils.proxymethod('fix', '__tag_engine__', 'filltaggaps', ! doc='check for tag consistency', explicit_self=True) #--------------------------------------------TagSetWithTagChainsMixin--- ! # XXX do we need chain-specific select??? class TagSetTagChainMixin(object): ''' + a chain is a tuple of tags. + + the tag chain structure is as follows: + + title <-------> Terminator + \ / + \ / + \ / + v v + (title, Terminator) + + - all the chain elements tag the chain (all-one). + - all chain elements are linked (all-all). NOTE: this must be mixed with a valid tagset. *************** *** 145,149 **** __chain_tag__ = 'TAGCHAIN' ! # tag-chain specific methods... def _ischain(self, tag): ''' --- 156,190 ---- __chain_tag__ = 'TAGCHAIN' ! # tag interface... ! def addtags(self, *tags): ! ''' ! ''' ! tags, chains = self._splitchains(tags) ! # process chains... ! self._addchains(*chains) ! super(TagSetTagChainMixin, self).addtags(*tags) ! ##!!! return?? ! def tag(self, obj, *tags): ! ''' ! ''' ! tags, chains = self._splitchains(tags) ! self._addchains(*chains) ! return super(TagSetTagChainMixin, self).tag(obj, *(tags+chains)) ! def _rawtag(self, obj, *tags): ! ''' ! ''' ! tags, chains = self._splitchains(tags) ! self._addchains(*chains) ! return super(TagSetTagChainMixin, self)._rawtag(obj, *(tags+chains)) ! # XXX this may be usefull for garbage collection... ! ## def untag(self, obj, *tags): ! ## ''' ! ## ''' ! ## tags, chaintags, chains = self._splitchains(tags) ! ## # XXX process chains... ! ## ##!!! ! ## super(TagSetTagChainMixin, self).untag(obj, *tags) ! ## ##!!! return?? ! # chain-specific helpers... def _ischain(self, tag): ''' *************** *** 153,168 **** return True return False - @staticmethod - def chain2tags(chain): - ''' - return the tags in chain. - ''' - # XXX check if cahin is a chain???? - return tuple(chain) - @staticmethod - def tags2chain(*tags): - ''' - ''' - return tags def _splitchains(self, tags): ''' --- 194,197 ---- *************** *** 180,184 **** t += (tag,) return t, c - ##!!! def _addchains(self, *chains): ''' --- 209,212 ---- *************** *** 192,241 **** else: self._rawtag(c, *(t+(tags.TAG_TAG,))) ! ##!!! is this correct??? self.__tag_engine__.link(self, c, *t) ! ! # tag interface... ! def addtags(self, *tags): ! ''' ! ''' ! tags, chains = self._splitchains(tags) ! # process chains... ! self._addchains(*chains) ! super(TagSetTagChainMixin, self).addtags(*tags) ! ##!!! return?? ! def tag(self, obj, *tags): ''' ''' ! tags, chains = self._splitchains(tags) ! self._addchains(*chains) ! return super(TagSetTagChainMixin, self).tag(obj, *(tags+chains)) ! def _rawtag(self, obj, *tags): ''' ''' ! tags, chains = self._splitchains(tags) ! self._addchains(*chains) ! return super(TagSetTagChainMixin, self)._rawtag(obj, *(tags+chains)) ! ## def untag(self, obj, *tags): ! ## ''' ! ## ''' ! ## tags, chaintags, chains = self._splitchains(tags) ! ## # XXX process chains... ! ## ##!!! ! ## super(TagSetTagChainMixin, self).untag(obj, *tags) ! ## ##!!! return?? ! ##!!! is this correct??? ! def relatedtags(self, *tags): ! ''' ''' ! tags, chains = self._splitchains(tags) ! return super(TagSetTagChainMixin, self).relatedtags(*(tags+chains)) ! ##!!! is this correct??? ! # XXX add more specific chain searches... ! def select(self, *tags): ! ''' ''' tags, chains = self._splitchains(tags) ! return super(TagSetTagChainMixin, self).select(*(tags+chains)) --- 220,252 ---- else: self._rawtag(c, *(t+(tags.TAG_TAG,))) ! # links all the tags in a chain... self.__tag_engine__.link(self, c, *t) ! # tag-chain specific methods... ! @staticmethod ! def chain2tags(chain): ''' + return the tags in chain. ''' ! # XXX check if cahin is a chain???? ! return tuple(chain) ! @staticmethod ! def tags2chain(*tags): ''' ''' ! return tags ! def chains(self, *tags): ''' ! return all the chains that contain tags. ! NOTE: of chains are given, then all the tags in them will be ! added to the search. ''' tags, chains = self._splitchains(tags) ! tags = set(tags) ! for chain in chains: ! tags.update(self.chain2tags(chain)) ! # collect all related chains... ! res = self.select(self.__chain_tag__, *tags) ! return res *************** *** 274,279 **** #--------------------------------------------------------------TagSet--- - ##class TagSet(TagSetMixin, dict): - ##class TagSet(TagSetTagChainMixin, TagSetMixin, dict): class TagSet(StringTagChainMixin, TagSetTagChainMixin, TagSetMixin, dict): ''' --- 285,288 ---- *************** *** 283,286 **** --- 292,296 ---- #------------------------------------------------TagSetWithSplitStore--- + ##!!! bring this up to date to support tag chains... # in geniral this should generate a unique string id for each stored # object and use that id in the tag store while storing the objects by *************** *** 473,483 **** # chains... ts.tag(o0, 'aaa:bbb') ! print ts.select('aaa') - #======================================================================= # vim:set ts=4 sw=4 nowrap : --- 483,496 ---- # chains... ts.tag(o0, 'aaa:bbb') + ts.tag(o1, 'aaa:ccc') ! print ts.select('aaa', 'TAGCHAIN') ! print ts.relatedtags('aaa') ! print ts.chains('aaa') ! ## print ts.relatedtags('aaa:bbb') #======================================================================= # vim:set ts=4 sw=4 nowrap : Index: generic.py =================================================================== RCS file: /cvsroot/pli/pli-devel/pli/tags/generic.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** generic.py 7 Mar 2008 10:30:34 -0000 1.15 --- generic.py 7 Mar 2008 11:34:38 -0000 1.16 *************** *** 2,6 **** __version__ = '''0.3.07''' ! __sub_version__ = '''20080307125708''' __copyright__ = '''(c) Alex A. Naanou 2007''' --- 2,6 ---- __version__ = '''0.3.07''' ! __sub_version__ = '''20080307142513''' __copyright__ = '''(c) Alex A. Naanou 2007''' *************** *** 222,225 **** --- 222,237 ---- + #---------------------------------------------------------iterorphans--- + def iterorphans(tagdb): + ''' + iterate orpahed tags. + ''' + for k, v in tagdb.items(): + if v == None or len(v.difference((TAG_TAG, OBJECT_TAG))) == 0: + # XXX do we need this check??? + if len(tags(tagdb, k).difference((TAG_TAG, OBJECT_TAG))) == 0: + yield k + + #----------------------------------------------------------------------- *************** *** 300,303 **** --- 312,317 ---- if tag not in tagdb: tagdb[tag] = tdbset() + # XXX should this tag the tag with TAG_TAG??? + _tag(tagdb, tag, TAG_TAG) *************** *** 457,460 **** --- 471,475 ---- #-------------------------------------------------------------iselect--- + ##!!! def iselect(tagdb, *tags): ''' *************** *** 557,560 **** --- 572,578 ---- print exclude(ts1, select(ts1, 'Y'), 'X') + print list(iterorphans(ts1)) + print tags(ts1, 'a') + print tags(ts1, 'aaa') |