mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-12 04:24:27 +00:00
Remove pythonize module since it's no longer used
This commit is contained in:
parent
eda19c3d60
commit
47bb52f72a
@ -1,38 +0,0 @@
|
|||||||
"""
|
|
||||||
some dbus to python type conversions
|
|
||||||
-decorator for interface
|
|
||||||
-wrapper class for proxy
|
|
||||||
"""
|
|
||||||
def pythonize(var):
|
|
||||||
"""translates dbus types back to basic python types."""
|
|
||||||
if isinstance(var, list):
|
|
||||||
return [pythonize(value) for value in var]
|
|
||||||
if isinstance(var, tuple):
|
|
||||||
return tuple([pythonize(value) for value in var])
|
|
||||||
if isinstance(var, dict):
|
|
||||||
return dict(
|
|
||||||
[(pythonize(key), pythonize(value)) for key, value in var.iteritems()]
|
|
||||||
)
|
|
||||||
|
|
||||||
for klass in [unicode, str, bool, int, float, long]:
|
|
||||||
if isinstance(var,klass):
|
|
||||||
return klass(var)
|
|
||||||
return var
|
|
||||||
|
|
||||||
def pythonize_call(func):
|
|
||||||
def deco(*args,**kwargs):
|
|
||||||
return pythonize(func(*args, **kwargs))
|
|
||||||
return deco
|
|
||||||
|
|
||||||
def pythonize_interface(func):
|
|
||||||
def deco(*args, **kwargs):
|
|
||||||
args = pythonize(args)
|
|
||||||
kwargs = pythonize(kwargs)
|
|
||||||
return func(*args, **kwargs)
|
|
||||||
return deco
|
|
||||||
|
|
||||||
class PythonizeProxy(object):
|
|
||||||
def __init__(self,proxy):
|
|
||||||
self.proxy = proxy
|
|
||||||
def __getattr__(self, key):
|
|
||||||
return pythonize_call(getattr(self.proxy, key))
|
|
Loading…
x
Reference in New Issue
Block a user