• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sudsobject.asdict函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中suds.sudsobject.asdict函数的典型用法代码示例。如果您正苦于以下问题:Python asdict函数的具体用法?Python asdict怎么用?Python asdict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了asdict函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: suds_to_dict

def suds_to_dict(obj):
  """Converts a suds object instance to a dict."""
  mapping = _SUDS_MAP.get(obj.__class__.__name__)
  if mapping is None:
    return sudsobject.asdict(obj)
  return dict(
      (mapping[k], v) for k, v in sudsobject.asdict(obj).items() if k in mapping
  )
开发者ID:Arunkk1985,项目名称:html5-to-dfp,代码行数:8,代码来源:dfp_utils.py


示例2: convert_entity_to_dict

def convert_entity_to_dict(entity):
    if has_udfs(entity):
        udfs = get_udfs(entity)
        udfs_list = []
        for udf in udfs:
            udfs_list.append(asdict(udf))
        entity.UserDefinedFields = udfs_list
    else:
        del_user_defined_fields_attribute(entity)
    return asdict(entity)
开发者ID:MattParr,项目名称:python-atws,代码行数:10,代码来源:asdict.py


示例3: recursive_asdict

    def recursive_asdict(self, d):
        from suds.sudsobject import asdict

        """Convert Suds object into serializable format."""
        out = {}
        if type(d) is not dict:
            d = asdict(d)

        for k, v in d.items():
            if hasattr(v, '__keylist__'):
                out[k] = self.recursive_asdict(v)
            elif isinstance(v, list):
                out[k] = []
                for item in v:
                    if hasattr(item, '__keylist__'):
                        out[k].append(self.recursive_asdict(item))
                    else:
                        out[k].append(item)

            elif v:
                # if v is True or k in ['lastModifiedDate', 'createdDate', 'lastPublishedDate']:
                # print (k, v)
                try:
                    # out[k] = BeautifulStoneSoup(v)
                    out[k] = v.encode('ascii', 'xmlcharrefreplace')
                except:
                    out[k] = v
                # else:

                # uni = self.HTMLEntitiesToUnicode(v)
                # htmlent = self.unicodeToHTMLEntities(uni)
                # out[k] = htmlent

        return out
开发者ID:betheluniversity,项目名称:cascade,代码行数:34,代码来源:cascade_connector.py


示例4: remove_default_tags

def remove_default_tags(d):
    out = {}
    for k, v in asdict(d).items():
        if k not in ('_ctiid', '_uuid'):
            if v:
                if v not in ('None', '', 'Default'):
                    if hasattr(v, '__keylist__'):
                        if hasattr(v, 'value'):
                            if v.value:
                                if v.value not in ('None', '', 'Default'):
                                    out[k] = v.value
                        else:
                            out[k] = remove_default_tags(v)
                    elif isinstance(v, list):
                        out[k] = []
                        for item in v:
                            if hasattr(item, '__keylist__'):
                                out[k].append(remove_default_tags(item))
                            else:
                                if item not in ('None', '', 'Default'):
                                    if item:
                                        out[k].append(item)
                    else:
                        out[k] = v
    return out
开发者ID:MrCollaborator,项目名称:CiscoUCScripts,代码行数:25,代码来源:helper_functions.py


示例5: recursive_asdict

def recursive_asdict(d):
    """
    Convert Suds object into serializable format (dictonary).

    Requires: d -- the input suds object

    Returns:  out -- a dictionary representation od d
    """

    from suds.sudsobject import asdict

    out = {}
    for key, value in asdict(d).iteritems():
        if hasattr(value, '__keylist__'):
            out[key] = recursive_asdict(value)
        elif isinstance(value, list):
            out[key] = []
            for item in value:
                if hasattr(item, '__keylist__'):
                    out[key].append(recursive_asdict(item))
                else:
                    out[key].append(item)
        else:
            out[key] = value

    return out
开发者ID:dengchangtao,项目名称:bagis-basin-analysis-gis,代码行数:26,代码来源:get_AWDB_stations.py


示例6: ensure_instance

    def ensure_instance(cls, model, the_data, allow_list=False, allow_none=False):
        if the_data is None and allow_none:
            return None

        if not isinstance(the_data, model):
            if isinstance(the_data, SudsObject):
                the_data = asdict(the_data)

            if isinstance(the_data, (list, tuple)):
                if not allow_list:
                    raise Exception('BaseDigidocServiceObject.ensure_instance: Lists not allowed in this context')

                result = []

                for item in the_data:
                    result.append(model.from_dict(item))

                return result

            elif isinstance(the_data, dict):
                return model.from_dict(the_data)

            else:
                raise Exception('BaseDigidocServiceObject.ensure_instance: The data must be one of: [cls, list, tuple, dict]')

        else:
            # It's an instance of the required class, all good
            return the_data
开发者ID:thorgate,项目名称:django-esteid,代码行数:28,代码来源:models.py


示例7: from_dict

    def from_dict(cls, the_data):
        if isinstance(the_data, SudsObject):
            the_data = asdict(the_data)

        kwargs = BaseDigidocServiceObject.camel_2_py(the_data)

        return cls(**kwargs)
开发者ID:thorgate,项目名称:django-esteid,代码行数:7,代码来源:models.py


示例8: __new__

    def __new__(cls, *args, **kwargs):
        _apientity = None
        obj_type = None
        if 'TypeRecord' in kwargs:
            _apientity = kwargs.get('TypeRecord', None)
            _apientity_dict = asdict(_apientity)
            if len(_apientity_dict) == 0:
                return None
            obj_type = _apientity_dict.get('type', None)
            del kwargs['TypeRecord']
        kwargs['data'] = _apientity
        kwargs['data_dict'] = _apientity_dict
        if obj_type is not None:
            if obj_type.lower() == 'zone':
                return Zone(*args, **kwargs)
            if obj_type.lower() == 'configuration':
                return Configuration(*args, **kwargs)
            if obj_type.lower() == 'view':
                return View(*args, **kwargs)
            if obj_type.lower() == 'hostrecord':
                return HostRecord(*args, **kwargs)
            if obj_type.lower() == 'mxrecord':
                return MXRecord(*args, **kwargs)
            if obj_type.lower() == 'txtrecord':
                return TXTRecord(*args, **kwargs)
            if obj_type.lower() == 'aliasrecord':
                return CNAMERecord(*args, **kwargs)
            if obj_type.lower() == 'hinforecord':
                return HINFORecord(*args, **kwargs)
            if obj_type.lower() == 'srvrecord':
                return SRVRecord(*args, **kwargs)

        return None
开发者ID:dillten,项目名称:proteus-api,代码行数:33,代码来源:apientity.py


示例9: recursive_asdict

def recursive_asdict(obj):
    """
    Convert Suds object into a dict so it can be serialized.
    Taken (mostly) from: http://stackoverflow.com/a/15678861

    @param obj, sudsobject: the suds object to be converted to dict
    @return dict: the object converted to a dict
    """
    # Don't convert a dict
    if isinstance(obj, dict):
        return obj

    out = {}
    for key, val in asdict(obj).iteritems():
        if hasattr(val, '__keylist__'):
            out[_underscore_key(key)] = recursive_asdict(val)
        elif isinstance(val, list):
            out[_underscore_key(key)] = []
            for item in val:
                if hasattr(item, '__keylist__'):
                    out[_underscore_key(key)].append(recursive_asdict(item))
                else:
                    out[_underscore_key(key)].append(to_string(item))
        else:
            out[_underscore_key(key)] = to_string(val)
    return out
开发者ID:apsharkey,项目名称:parselmouth,代码行数:26,代码来源:utils.py


示例10: register_account

    def register_account(self, registration):
        """Register a new account.

        :param registration: Registration instance.
        """
        arguments = asdict(registration)

        return self.call("RegisterAccount", **arguments)
开发者ID:snosrap,项目名称:stamps,代码行数:8,代码来源:services.py


示例11: load

 def load(self):
     super(HourlyDataIO, self).load()
     if self.data and 'values' in self.data[0]:
         self.data = [
             asdict(row)
             for row in as_list(self.data[0]['values'])
         ]
     else:
         raise NoData
开发者ID:heigeo,项目名称:climata,代码行数:9,代码来源:__init__.py


示例12: dict

 def dict(cls, sobject):
     """
     Convert a sudsobject into a dictionary.
     @param sobject: A suds object
     @type sobject: L{Object}
     @return: A python dictionary containing the
         items contained in I{sobject}.
     @rtype: dict
     """
     return sudsobject.asdict(sobject)
开发者ID:jonathan-hepp,项目名称:suds,代码行数:10,代码来源:client.py


示例13: recursive_asdict

	def recursive_asdict(self,d):
		out = {}
		for k, v in asdict(d).iteritems():
			if hasattr(v, '__keylist__'):
				out[k] = self.recursive_asdict(v)
			elif isinstance(v, list):
				out[k] = []
				for item in v:
					if hasattr(item, '__keylist__'):
						out[k].append(self.recursive_asdict(item))
					else:
						out[k].append(item)
			else:
				out[k] = v
		return out
开发者ID:dvolvox,项目名称:PyCheckmarx,代码行数:15,代码来源:PyCheckmarx.py


示例14: resolve

def resolve(res):
    if hasattr(res, '__keylist__'):
        ret = {}
        for k, v in asdict(res).iteritems():
            ret[k] = resolve(v)
        return ret
    elif isinstance(res, list):
        ret = []
        for i in res:
            ret.append(resolve(i))
        return ret
    elif isinstance(res, basestring):
        return res and unicode(res) or None
    else:
        return res
开发者ID:BlackWizard,项目名称:django-misc-base,代码行数:15,代码来源:tasks.py


示例15: recursive_asdict

def recursive_asdict(data):
    """Convert Suds object into serializable format."""
    out = {}
    for key, val in asdict(data).iteritems():
        if hasattr(val, '__keylist__'):
            out[key] = recursive_asdict(val)
        elif isinstance(val, list):
            out[key] = []
            for item in val:
                if hasattr(item, '__keylist__'):
                    out[key].append(recursive_asdict(item))
                else:
                    out[key].append(item)
        else:
            out[key] = val
    return out
开发者ID:laycat,项目名称:platform-get,代码行数:16,代码来源:ingest.py


示例16: __suds_to_dict

 def __suds_to_dict(self, data):
     """Converte sudsobject para dict"""
     out = {}
     for key, value in list(asdict(data).items()):
         if hasattr(value, '__keylist__'):
             out[key] = self.__suds_to_dict(value)
         elif isinstance(value, list):
             out[key] = []
             for item in value:
                 if hasattr(item, '__keylist__'):
                     out[key].append(self.__suds_to_dict(item))
                 else:
                     out[key].append(item)
         else:
             out[key] = value
     return out
开发者ID:tiagoamx,项目名称:procapi,代码行数:16,代码来源:services.py


示例17: recursive_asdict

	def recursive_asdict(d):
		"""From http://stackoverflow.com/a/15678861"""
		out = {}
		for k, v in asdict(d).iteritems():
			if hasattr(v, '__keylist__'):
				out[k] = recursive_asdict(v)
			elif isinstance(v, list):
				out[k] = []
				for item in v:
					if hasattr(item, '__keylist__'):
						out[k].append(recursive_asdict(item))
					else:
						out[k].append(item)
			else:
				out[k] = v
		return out
开发者ID:Exeter,项目名称:connect--,代码行数:16,代码来源:test.py


示例18: to_dict

def to_dict(sudsobject):
	d = sudsobject
	out = {}
	for k, v in asdict(d).iteritems():
		if hasattr(v, '__keylist__'):
			out[k] = to_dict(v)
		elif isinstance(v, list):
			out[k] = []
			for item in v:
				if hasattr(item, '__keylist__'):
					out[k].append(to_dict(item))
				else:
					out[k].append(item)
		else:
			out[k] = v
	return out
开发者ID:Exeter,项目名称:PEA_connect,代码行数:16,代码来源:connect.py


示例19: recursive_asdict

def recursive_asdict(d):
    """Convert Suds object into serializable format."""
    out = {}
    for k, v in asdict(d).iteritems():
        if hasattr(v, '__keylist__'):
            out[k] = recursive_asdict(v)
        elif isinstance(v, list):
            out[k] = []
            for item in v:
                if hasattr(item, '__keylist__'):
                    out[k].append(recursive_asdict(item))
                else:
                    out[k].append(item)
        else:
            out[k] = v
    return out
开发者ID:jcjnyc,项目名称:dfp-api-python-data-pull,代码行数:16,代码来源:dfp_api_generic.py


示例20: recursive_asdict

def recursive_asdict(suds_data):
    ''' Convert Suds object into serializable format. '''

    out = {}
    for key, value in asdict(suds_data).items():
        if hasattr(value, '__keylist__'):
            out[key] = recursive_asdict(value)
        elif isinstance(value, list):
            out[key] = []
            for item in value:
                if hasattr(item, '__keylist__'):
                    out[key].append(recursive_asdict(item))
                else:
                    out[key].append(item)
        else:
            out[key] = value
    return out
开发者ID:loxley,项目名称:halonadm,代码行数:17,代码来源:halonadm.py



注:本文中的suds.sudsobject.asdict函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sudsobject.Facade类代码示例发布时间:2022-05-27
下一篇:
Python parser.Parser类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap