ThesaurusOrdered.clear() empty in reverse. ThesaurusExtended.keys() and .items() added with exclude= keyword arg.
Dave Cinege
11 months ago
0 | 0 |
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/
|
1 | 7 |
|
2 | 8 |
clean:
|
3 | 9 |
-rm *.pyc *.pyo
|
16 | 16 |
###
|
17 | 17 |
from __future__ import print_function
|
18 | 18 |
|
19 | |
__VERSION__ = (2, 9, 0, 20191110)
|
|
19 |
__VERSION__ = (2, 9, 1, 20220619)
|
20 | 20 |
|
21 | 21 |
from sys import version_info, getrecursionlimit
|
22 | 22 |
__PYTHON_ORDERED__ = version_info[0:2] >= (3,6) # cPython 3,6+ has ordered keys built in.
|
|
227 | 227 |
def items (self):
|
228 | 228 |
return list( (key, self[key]) for key in self.__keyorder )
|
229 | 229 |
def clear (self):
|
230 | |
for key in self.__keyorder:
|
|
230 |
for key in self.__keyorder[::-1]:
|
231 | 231 |
del self[key]
|
232 | |
del self.__keyorder[:]
|
233 | 232 |
def __iter__ (self):
|
234 | 233 |
return self.iterkeys()
|
235 | 234 |
def iterkeys (self):
|
|
365 | 364 |
if isinstance (key, int) or isinstance (key, slice):
|
366 | 365 |
return list(self.values())[key]
|
367 | 366 |
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 |
|
369 | 380 |
thesext = ThesaurusExtended
|
370 | 381 |
|
371 | 382 |
|