From aa4105b918f4a733cfe364e35653d183e305fd55 Mon Sep 17 00:00:00 2001 From: alex_nanou Date: Thu, 9 Sep 2004 13:02:54 +0000 Subject: [PATCH] *** empty log message *** --- CHANGES | 2 +- PKG-INFO | 2 +- pli/dispatch/mapping.py | 68 +++++++++++++++++++++++++++++++++++++++-- pli/interface/interface.py | 27 ++++++++++++++-- pli/pattern/store/stored.py | 2 +- pli/pattern/store/storeproxy.py | 7 ++--- 6 files changed, 95 insertions(+), 13 deletions(-) diff --git a/CHANGES b/CHANGES index 350df55..45f3000 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -# this file was generated on [200409091610] +# this file was generated on [200409091701] pli changes: version 0.0.84 (200409091457): diff --git a/PKG-INFO b/PKG-INFO index 66b2d27..ad21ca7 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: pli -Version: 0.0.84 +Version: 0.0.85 Summary: PLI: a utility library for the Python language. Home-page: http://pli.sourceforge.net/ Author: Alex A. Naanou diff --git a/pli/dispatch/mapping.py b/pli/dispatch/mapping.py index 3448f38..f499561 100755 --- a/pli/dispatch/mapping.py +++ b/pli/dispatch/mapping.py @@ -1,7 +1,7 @@ #======================================================================= __version__ = '''0.0.01''' -__sub_version__ = '''20040909160930''' +__sub_version__ = '''20040909163249''' __copyright__ = '''(c) Alex A. Naanou 2003''' @@ -18,7 +18,7 @@ import pli.interface as interface #----------------------------------------------------------------------- #------------------------------------------------BasicMappingDispatch--- # this is a mapping mixin.... -class BasicMappingDispatch(BasicDispatch, mapping.BasicMapping): +class BasicMappingDispatch(dispatch.BasicDispatch, mapping.BasicMapping): ''' this is a mapping dispatch object. @@ -39,7 +39,7 @@ class BasicMappingDispatch(BasicDispatch, mapping.BasicMapping): def __setitem__(self, name, value): ''' ''' - self.reslove(valuse)[name] = value + self.resolve(value)[name] = value def __delitem__(self, name): ''' ''' @@ -80,4 +80,66 @@ class BasicMappingInterfaceDispatch(BasicMappingDispatch): #======================================================================= +if __name__ == '__main__': + + class IA(interface.Interface): + __format__ = { + 'aaa' : { + 'type': int, + 'default': 321, + }, + '*' : { + 'LIKE': 'aaa', + 'type': str, + }, + } + + class IB(IA): + __foramt__ = { + 'bbb' : { + 'type': str, + 'default': '', + }, + } + + class A(interface.ObjectWithInterface): + __implemments__ = IA + + class B(interface.ObjectWithInterface): + __implemments__ = IB + + store = BasicMappingInterfaceDispatch() + IAStore = {} + store.addrule((IA,), IAStore) + IBStore = {} + store.addrule((IB,), IBStore) + + + a0 = A() + a1 = A() + a2 = A() + + b0 = B() + b1 = B() + b2 = B() + + store['a0'] = a0 + store['a1'] = a1 + store['a2'] = a2 + + store['b0'] = b0 + store['b1'] = b1 + store['b2'] = b2 + + print IAStore + print IBStore + + print store['a0'] == a0 + print store['b1'] == b1 + + print [ k for k in store ] + + + +#======================================================================= # vim:set ts=4 sw=4 nowrap : diff --git a/pli/interface/interface.py b/pli/interface/interface.py index b82cfe9..057aa68 100755 --- a/pli/interface/interface.py +++ b/pli/interface/interface.py @@ -1,7 +1,7 @@ #======================================================================= -__version__ = '''0.2.17''' -__sub_version__ = '''20040831004734''' +__version__ = '''0.2.19''' +__sub_version__ = '''20040909170101''' __copyright__ = '''(c) Alex A. Naanou 2003''' @@ -328,6 +328,29 @@ def getinterfaces(obj): return (obj.__implemments__,) +#-------------------------------------------------------------getdata--- +def getdata(obj, interface=None): + ''' + this will return a dict containing the data taken from the object in compliance + to the interface. + ''' + if interface != None: + format = interface + else: + format = logictypes.DictUnion(*getinterfaces(obj)[::-1]) + res = {} + for k in format: + if not hasattr(obj, k): + format_k = format[k] + if 'default' in format_k: + res[k] = format_k['default'] + elif format_k.get('essential', False): + raise InterfaceError, 'object %s does not have an essential attribute "%s".' % (obj, k) + else: + res[k] = getattr(obj, k) + return res + + #----------------------------------------------------------checkvalue--- def checkvalue(obj, name, value, interface=None): ''' diff --git a/pli/pattern/store/stored.py b/pli/pattern/store/stored.py index a48e833..f9f6266 100644 --- a/pli/pattern/store/stored.py +++ b/pli/pattern/store/stored.py @@ -1,7 +1,7 @@ #======================================================================= __version__ = '''0.0.11''' -__sub_version__ = '''20040907143557''' +__sub_version__ = '''20040909163900''' __copyright__ = '''(c) Alex A. Naanou 2003''' diff --git a/pli/pattern/store/storeproxy.py b/pli/pattern/store/storeproxy.py index e33fdbd..18c2f3b 100644 --- a/pli/pattern/store/storeproxy.py +++ b/pli/pattern/store/storeproxy.py @@ -1,7 +1,7 @@ #======================================================================= __version__ = '''0.0.05''' -__sub_version__ = '''20040821212328''' +__sub_version__ = '''20040909163609''' __copyright__ = '''(c) Alex A. Naanou 2003''' @@ -11,7 +11,7 @@ import pli.pattern.store as store #----------------------------------------------------------------------- - +#------------------------------------------------------BaseStoreProxy--- SAFE_TRNSFER=0 FORCE_OVERWRITE=1 # this stop the overwriting of data in the target backend... @@ -60,9 +60,6 @@ class BaseStoreProxy(store.BaseStore): self._setbackend(backend) - - - #======================================================================= # vim:set ts=4 sw=4 nowrap : -- 2.11.4.GIT