From 281b828afa84d9458953aaaa6e3aef3718d8d6a3 Mon Sep 17 00:00:00 2001 From: alex_nanou Date: Sun, 28 Mar 2004 15:25:08 +0000 Subject: [PATCH] *** empty log message *** --- PKG-INFO | 2 +- pli/functional.py | 2 +- pli/importutils.py | 7 +- pli/logictypes.py | 241 ++++++++++++++++++++++++++++++++++++++++++++++++ pli/net/rpcsession.py | 2 +- pli/net/xmlrpcserver.py | 4 +- pli/objutils.py | 6 +- setup.py | 3 +- 8 files changed, 253 insertions(+), 14 deletions(-) create mode 100755 pli/logictypes.py diff --git a/PKG-INFO b/PKG-INFO index 251f897..a8ff387 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: pli -Version: 0.0.19 +Version: 0.0.20 Summary: PLI: a utility library for the Python language. Home-page: http://pli.sourceforge.net/ Author: Alex A. Naanou diff --git a/pli/functional.py b/pli/functional.py index 65824d9..0ab6287 100644 --- a/pli/functional.py +++ b/pli/functional.py @@ -1,7 +1,7 @@ #======================================================================= __version__ = '''0.5.08''' -__sub_version__ = '''20040227014952''' +__sub_version__ = '''20040328151509''' __copyright__ = '''(c) Alex A. Naanou 2003''' diff --git a/pli/importutils.py b/pli/importutils.py index 3aae267..4561852 100644 --- a/pli/importutils.py +++ b/pli/importutils.py @@ -1,7 +1,7 @@ #======================================================================= -__version__ = '''0.0.14''' -__sub_version__ = '''20040326130605''' +__version__ = '''0.0.17''' +__sub_version__ = '''20040326131151''' __copyright__ = '''(c) Alex A. Naanou 2003''' @@ -69,7 +69,8 @@ def ispythonimportable(package_dir, name): #---------------------------------------------------------packageiter--- -def packageiter(package_dir, disable_file='disabled.txt', disabled_packages=None, notimportable=None, ignore_modules=()): +def packageiter(package_dir, disable_file='disabled.txt', \ + disabled_packages=None, notimportable=None, ignore_modules=()): '''\ This will return importable (and enabled) package names (without importing). diff --git a/pli/logictypes.py b/pli/logictypes.py new file mode 100755 index 0000000..1d37cca --- /dev/null +++ b/pli/logictypes.py @@ -0,0 +1,241 @@ +#======================================================================= + +__version__ = '''0.0.03''' +__sub_version__ = '''20040328193355''' +__copyright__ = '''(c) Alex A. Naanou 2003''' + +__doc__ = '''\ +this module defines a number of utilities and objects to assist advanced +usage of standard python types. +''' + +#----------------------------------------------------------------------- + + + +#----------------------------------------------------------------------- +#-------------------------------------------------------dictcopyunite--- +def dictcopyunite(*members): + ''' + ''' + res = {} + for m in members: + res.update(m) + return res + + +#-----------------------------------------------------------DictUnion--- +class DictUnion(object): + ''' + this is a dict like object, that acts as a union of its members but + without modifieng its members in any way. + + this is similar to a sequential update of all members, but retains + the container information for each item, and does not have the + overhead of creating a new resulting dict. + + NOTE: because of the nature of dicts, the later added members (unite) + have higher priority than the former. + NOTE: the members added in one call (be it __init__, unite or tailunite) + have descending priority -- first highest last lowest. + NOTE: due to ints nature this object is *live*, e.g. it emidiatly + reflects all modifications to its members as they are modified. + ''' + _members = () + + def __init__(self, *members): + ''' + ''' + members = list(members) + members.reverse() + self._members = tuple(members) + def __getitem__(self, name): + ''' + ''' + for m in self._members: + if name in m: + return m[name] + raise KeyError, 'key "%s" is not present in any of the members.' % name +## def __setitem__(self, name, value): +## ''' +## ''' +## # find source... +## # set +## raise TypeError, 'can\'t add values to a dict union object.' +## def __delitem__(self, name): +## ''' +## ''' +## raise TypeError, 'can\'t delete values from a dict union object.' + def __contains__(self, name): + ''' + ''' + for m in self._members: + if name in m: + return True + return False + def __iter__(self): + ''' + ''' + seen = [] + for m in self._members: + for n in m: + if n not in seen: + seen += [n] + yield n +## def __len__(self): +## ''' +## ''' +## pass +## def __cmp__(self): +## ''' +## ''' +## pass +## def __eq__(self): +## ''' +## ''' +## pass +## def __ge__(self): +## ''' +## ''' +## pass +## def __gt__(self): +## ''' +## ''' +## pass +## def __le__(self): +## ''' +## ''' +## pass +## def __lt__(self): +## ''' +## ''' +## pass +## def __ne__(self): +## ''' +## ''' +## pass +## def __repr__(self): +## ''' +## ''' +## pass +## def __str__(self): +## ''' +## ''' +## pass +## def __reduce__(self): +## ''' +## ''' +## pass +## def __reduce_ex__(self): +## ''' +## ''' +## pass + def keys(self): + ''' + ''' + return list(self) + def values(self): + ''' + ''' + return list(self.itervalues()) + def items(self): + ''' + ''' + return list(self.iteritems()) + def iterkeys(self): + ''' + ''' + return self.__iter__() + def itervalues(self): + ''' + ''' + for k in self: + yield self[k] + def iteritems(self): + ''' + ''' + for k in self: + yield k, self[k] + def get(self, name, dfl=None): + ''' + ''' + try: + return self[name] + except KeyError: + if dfl == None: + raise + return dfl + def has_key(self, name): + ''' + ''' + return name in self +## def setdefault(self): +## ''' +## ''' +## pass + # the dict union specific interface... + ##!!! revise... + def unite(self, *others): + ''' + add members to the union object. + + NOTE: this method will add members to the top of the pririty + stack. + ''' + others = list(others) + others.reverse() + self._members = tuple(others) + self._members + ##!!! revise... + def tailunite(self, *others): + ''' + this is the same as unite but adds low priority members (to the + botom of the priority stack). + ''' + others = list(others) + others.reverse() + self._members = self._members + tuple(others) + def removemember(self, obj): + ''' + ''' + if obj in self._members: + self._members = tuple(list(self._members).remove(obj)) + return + raise TypeError, '%s does not contain %s as a member.' % (self, obj) + def members(self): + ''' + ''' + return self._members + def itermembers(self): + ''' + ''' + for m in self._members: + yield m + def getcontainerof(self, name): + ''' + ''' + for m in self._members: + if name in m: + return m + raise KeyError, '%s does not contain "%s"' % (self, name) + def getallcontainersof(self, name): + ''' + ''' + res = [] + for m in self._members: + if name in m: + res += [m] + if res == []: + raise KeyError, '%s does not contain "%s"' % (self, name) + return res + + +#-----------------------------------------------------------ListUnion--- +##def ListUnion(list): +## ''' +## ''' +## pass + + + +#======================================================================= +# vim:set ts=4 sw=4 nowrap : diff --git a/pli/net/rpcsession.py b/pli/net/rpcsession.py index ffab306..f488022 100644 --- a/pli/net/rpcsession.py +++ b/pli/net/rpcsession.py @@ -1,7 +1,7 @@ #======================================================================= __version__ = '''0.1.39''' -__sub_version__ = '''20040322161031''' +__sub_version__ = '''20040328163952''' __copyright__ = '''(c) Alex A. Naanou 2003''' diff --git a/pli/net/xmlrpcserver.py b/pli/net/xmlrpcserver.py index 4e93f3f..2604864 100644 --- a/pli/net/xmlrpcserver.py +++ b/pli/net/xmlrpcserver.py @@ -1,7 +1,7 @@ #======================================================================= -__version__ = '''0.0.01''' -__sub_version__ = '''20040201054234''' +__version__ = '''0.0.07''' +__sub_version__ = '''20040328194423''' __copyright__ = '''(c) Alex A. Naanou 2003-2004''' diff --git a/pli/objutils.py b/pli/objutils.py index ca8a769..ecbcac3 100644 --- a/pli/objutils.py +++ b/pli/objutils.py @@ -1,7 +1,7 @@ #======================================================================= __version__ = '''0.0.12''' -__sub_version__ = '''20040227011349''' +__sub_version__ = '''20040328143634''' __copyright__ = '''(c) Alex A. Naanou 2003''' @@ -56,10 +56,6 @@ class ObjectWithAttrs(object): ''' super(ObjectWithAttrs, self).__init__(name) # check essential attrs.... -## if hasattr(self, '__essential_attrs__') and self.__essential_attrs__ != None and \ -## False in [ (type(attr) not in (str, unicode) and attr[0] or attr) in attrs \ -## for attr in self.__essential_attrs__ ]: -## raise TypeError, 'essential attribute format mismatch.' if hasattr(self, '__essential_attrs__') and self.__essential_attrs__ != None: essential_attrs = [ (type(attr) not in (str, unicode) and attr[0] or attr) \ for attr in self.__essential_attrs__ ] diff --git a/setup.py b/setup.py index 72450e0..6e417f6 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #======================================================================= __version__ = '''0.1.12''' -__sub_version__ = '''20040314235444''' +__sub_version__ = '''20040326192833''' __copyright__ = '''(c) Alex A. Naanou 2003''' @@ -66,6 +66,7 @@ setup( 'pli.event', 'pli.misc', 'pli.net', +## 'pli.unit', 'pli.pattern', 'pli.pattern.proxy', 'pli.pattern.state', -- 2.11.4.GIT