当前位置: 首页>>代码示例>>Python>>正文


Python Product.insert_json方法代码示例

本文整理汇总了Python中product.Product.insert_json方法的典型用法代码示例。如果您正苦于以下问题:Python Product.insert_json方法的具体用法?Python Product.insert_json怎么用?Python Product.insert_json使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在product.Product的用法示例。


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

示例1: fetch

# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import insert_json [as 别名]
 def fetch(self, handle, id):
     from product import Product
     from artist import Artist
     jtrack = qobuz.api.get_track(id)
     if not jtrack:
         print "Cannot fetch data"
         return False
     print pprint.pformat(jtrack)
     where = {}
     if 'album' in jtrack:
         P = Product()
         album = P.get(handle, jtrack['album']['id'])
         if not album:
             P.insert_json(handle, jtrack['album'])
     for field in self.fields_name.keys():
         f = self.fields_name[field]
         if not f['jsonmap']: continue
         value = self.get_property(jtrack, f['jsonmap'])
         if not value: continue
         where[field] = value
     if 'interpreter' in jtrack:
         I = Artist()
         interpreter = I.get(handle, jtrack['interpreter'])
         if not interpreter:
             I.insert(handle, jtrack['interpreter'])
     if 'performer' in jtrack:
         I = Artist()
         interpreter = I.get(handle, jtrack['performer'])
         if not interpreter:
             I.insert(handle, jtrack['performer'])
     artist = None
     artist_type = ('artist', 'interpreter', 'composer', 'performer')
     for a in artist_type:
         if a in jtrack and jtrack[a]['name'] and jtrack[a]['name'] != 'None':
             artist = jtrack[a]
             break
     self.insert(handle, where)
     return False
开发者ID:tidalf,项目名称:dc.xbmc.addons,代码行数:40,代码来源:track.py

示例2: insert_json

# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import insert_json [as 别名]
 def insert_json(self, handle, json):
     print "JSON: " + pprint.pformat(json)
     from product import Product
     from artist import Artist
     where = {}
     subtype = ['album', 'interpreter', 'composer', 'performer']
     for type in subtype:
         if type in json:
             db = None
             if type == 'album': db = Product()
             elif type in ['interpreter', 'composer', 'performer']: 
                 db = Artist()
             if not 'id' in json[type] or not json[type]['id']: continue
             if not db.get(handle, int(json[type]['id'])):
                 db.insert_json(handle, json[type])
     for field in self.fields_name.keys():
         f = self.fields_name[field]
         if not f['jsonmap']: continue
         value = self.get_property(json, f['jsonmap'])
         if not value: continue
         where[field] = value
     print "Where %s" % (pprint.pformat(where))
     return self.insert(handle, where)
开发者ID:tidalf,项目名称:dc.xbmc.addons,代码行数:25,代码来源:track.py


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