Dave Cinege Git Repo thesaurus / 3883746
ThesaurusOrdered.clear() empty in reverse. ThesaurusExtended.keys() and .items() added with exclude= keyword arg. Dave Cinege 7 days ago
2 changed file(s) with 21 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
00 all:
1
2 ssuinstall:
3
4 ssu install -m 644 thesaurus.py thesauruscfg.py /usr/local/lib/python2.7/dist-packages/
5 ssu install -m 644 thesaurus.py thesauruscfg.py /usr/local/lib/python3.6/dist-packages/
6 ssu install -m 644 thesaurus.py thesauruscfg.py /usr/local/lib/python3.8/site-packages/
17
28 clean:
39 -rm *.pyc *.pyo
1616 ###
1717 from __future__ import print_function
1818
19 __VERSION__ = (2, 9, 0, 20191110)
19 __VERSION__ = (2, 9, 1, 20220619)
2020
2121 from sys import version_info, getrecursionlimit
2222 __PYTHON_ORDERED__ = version_info[0:2] >= (3,6) # cPython 3,6+ has ordered keys built in.
227227 def items (self):
228228 return list( (key, self[key]) for key in self.__keyorder )
229229 def clear (self):
230 for key in self.__keyorder:
230 for key in self.__keyorder[::-1]:
231231 del self[key]
232 del self.__keyorder[:]
233232 def __iter__ (self):
234233 return self.iterkeys()
235234 def iterkeys (self):
365364 if isinstance (key, int) or isinstance (key, slice):
366365 return list(self.values())[key]
367366 return thes.__getitem__(self, key)
368
367 def keys (self, exclude=None):
368 if exclude == None:
369 return thes.keys(self)
370 if isinstance(exclude, str):
371 exclude = (exclude,)
372 return [ _key for _key in thes.keys(self) if _key not in exclude ]
373 def items (self, exclude=None):
374 if exclude == None:
375 return thes.items(self)
376 if isinstance(exclude, str):
377 exclude = (exclude,)
378 return [ (_key,_value) for _key,_value in thes.items(self) if _key not in exclude ]
379
369380 thesext = ThesaurusExtended
370381
371382