[Pli-devel] pli-devel/pli/tags generic.py,1.16,1.17
Status: Pre-Alpha
Brought to you by:
alex_nanou
|
From: Alex A. N. <ale...@us...> - 2008-03-07 11:59:16
|
Update of /cvsroot/pli/pli-devel/pli/tags In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12024/pli/tags Modified Files: generic.py Log Message: Index: generic.py =================================================================== RCS file: /cvsroot/pli/pli-devel/pli/tags/generic.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** generic.py 7 Mar 2008 11:34:38 -0000 1.16 --- generic.py 7 Mar 2008 11:59:05 -0000 1.17 *************** *** 2,6 **** __version__ = '''0.3.07''' ! __sub_version__ = '''20080307142513''' __copyright__ = '''(c) Alex A. Naanou 2007''' --- 2,6 ---- __version__ = '''0.3.07''' ! __sub_version__ = '''20080307145304''' __copyright__ = '''(c) Alex A. Naanou 2007''' *************** *** 122,126 **** - #----------------------------------------------------------------------- # helpers... --- 122,125 ---- *************** *** 185,193 **** #---------------------------------------------------------filltaggaps--- # XXX should these two be split?? - # XXX might be good make this an interactive generator so as to have - # more control over what is fixed and how... # XXX should this restore the tag to self?? # XXX might be good to make this explicitly depend on itertaggaps # (through arguments)... def filltaggaps(tagdb): ''' --- 184,192 ---- #---------------------------------------------------------filltaggaps--- # XXX should these two be split?? # XXX should this restore the tag to self?? # XXX might be good to make this explicitly depend on itertaggaps # (through arguments)... + # TODO make this an interactive generator so as to have more control + # over what is fixed and how... def filltaggaps(tagdb): ''' *************** *** 234,237 **** --- 233,262 ---- + #------------------------------------------------------------------gc--- + def gc(tagdb): + ''' + interactive garbage collector. + + this will iterate through the orphans and remove them. + + to skip the removal send the string 'skip' to the generator instance. + + Example: + + g = gc(tagdb) + + for tag in g: + if 'a' in tag: + g.send('skip') + + + WARNING: this will remove orphaned tags and objects. this list will + include tags added by addtags(..) but not yet used. + ''' + for tag in iterorphans(tagdb): + if (yield tag) != 'skip': + del tagdb[tag] + + #----------------------------------------------------------------------- *************** *** 572,578 **** print exclude(ts1, select(ts1, 'Y'), 'X') - print list(iterorphans(ts1)) print tags(ts1, 'a') print tags(ts1, 'aaa') --- 597,611 ---- print exclude(ts1, select(ts1, 'Y'), 'X') print tags(ts1, 'a') print tags(ts1, 'aaa') + print list(iterorphans(ts1)) + + # gc the orphans except for 'aaa' + g = gc(ts1) + for t in g: + if t == 'aaa': + g.send('skip') + + print list(iterorphans(ts1)) |