diff --git a/Makefile b/Makefile index bd6a80f..b282ade 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,10 @@ all: + +ssuinstall: + + ssu install -m 644 thesaurus.py thesauruscfg.py /usr/local/lib/python2.7/dist-packages/ + ssu install -m 644 thesaurus.py thesauruscfg.py /usr/local/lib/python3.6/dist-packages/ + ssu install -m 644 thesaurus.py thesauruscfg.py /usr/local/lib/python3.8/site-packages/ clean: -rm *.pyc *.pyo diff --git a/thesaurus.py b/thesaurus.py index 37ecf42..5ef847e 100644 --- a/thesaurus.py +++ b/thesaurus.py @@ -17,7 +17,7 @@ ### from __future__ import print_function -__VERSION__ = (2, 9, 0, 20191110) +__VERSION__ = (2, 9, 1, 20220619) from sys import version_info, getrecursionlimit __PYTHON_ORDERED__ = version_info[0:2] >= (3,6) # cPython 3,6+ has ordered keys built in. @@ -228,9 +228,8 @@ def items (self): return list( (key, self[key]) for key in self.__keyorder ) def clear (self): - for key in self.__keyorder: + for key in self.__keyorder[::-1]: del self[key] - del self.__keyorder[:] def __iter__ (self): return self.iterkeys() def iterkeys (self): @@ -366,7 +365,19 @@ if isinstance (key, int) or isinstance (key, slice): return list(self.values())[key] return thes.__getitem__(self, key) - + def keys (self, exclude=None): + if exclude == None: + return thes.keys(self) + if isinstance(exclude, str): + exclude = (exclude,) + return [ _key for _key in thes.keys(self) if _key not in exclude ] + def items (self, exclude=None): + if exclude == None: + return thes.items(self) + if isinstance(exclude, str): + exclude = (exclude,) + return [ (_key,_value) for _key,_value in thes.items(self) if _key not in exclude ] + thesext = ThesaurusExtended