mirror of
https://github.com/haiwen/libsearpc.git
synced 2025-09-09 08:39:30 +00:00
Do not encode object property in utf8
This commit is contained in:
@@ -9,8 +9,8 @@ class SearpcError(Exception):
|
||||
def __str__(self):
|
||||
return self.msg
|
||||
|
||||
class _SearpcObjProps(object):
|
||||
'''A compact class to emulate gobject.GProps
|
||||
class _SearpcObj(object):
|
||||
'''A compact class to emulate gobject.GObject
|
||||
'''
|
||||
def __init__(self, dicts):
|
||||
new_dict = {}
|
||||
@@ -18,26 +18,17 @@ class _SearpcObjProps(object):
|
||||
value = dicts[key]
|
||||
# replace hyphen with with underline
|
||||
new_key = key.replace('-', '_')
|
||||
# encode all strings in UTF-8
|
||||
if isinstance(value, unicode):
|
||||
value = value.encode('utf-8')
|
||||
new_dict[new_key] = value
|
||||
|
||||
self._dicts = new_dict
|
||||
# For compatibility with old usage peer.props.name
|
||||
self.props = self
|
||||
self._dict = new_dict
|
||||
|
||||
def __getattr__(self, key):
|
||||
try:
|
||||
return self._dicts[key]
|
||||
return self._dict[key]
|
||||
except:
|
||||
return None
|
||||
|
||||
class _SearpcObj(object):
|
||||
'''A compact class to emulate gobject.GObject
|
||||
'''
|
||||
def __init__(self, dicts):
|
||||
self.props = _SearpcObjProps(dicts)
|
||||
|
||||
|
||||
def _fret_obj(ret_str):
|
||||
try:
|
||||
dicts = json.loads(ret_str)
|
||||
@@ -52,7 +43,6 @@ def _fret_obj(ret_str):
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def _fret_objlist(ret_str):
|
||||
try:
|
||||
dicts = json.loads(ret_str)
|
||||
|
Reference in New Issue
Block a user