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


Python Item.title方法代码示例

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


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

示例1: create_digest

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import title [as 别名]
    def create_digest(self, item_type, github_items):
        """
        builds a DigestData instance filled with the digest
        """
        issue_list = list(self.get_issues())

        digest = DigestData(item_type)
        digest.user = self._user
        digest.repo = self._repository_name

        for github_item in github_items:
            if github_item.state == ItemStates.OPEN:
                digest.total_opened += 1
            elif github_item.state == ItemStates.CLOSED:
                digest.total_closed += 1

            digest.total_items += 1

            item = Item()
            item.url = github_item.html_url
            item.label = '{}/{}#{}'.format(self._user, self._repository_name, github_item.number)
            item.title = github_item.title
            item.state = github_item.state
            github_user = github_item.user

            display_name = github_user.name or github_user.login
            if display_name not in digest.users:
                user = User()
                user.name = display_name
                user.gravatar = github_user.avatar_url
                digest.users[display_name] = user

            digest.items.setdefault(display_name, []).append(item)

        return digest
开发者ID:rainforestapp,项目名称:digestive,代码行数:37,代码来源:digestive.py

示例2: save_entity

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import title [as 别名]
    def save_entity(self, _id=None, title='Test', items=[]):
        i = Item()
        if _id:
            i._id = _id
        i.title = title
        i.content = 'Some content'
        i.tagIds = [1,2,3]
        i.added = datetime.now()
        i.items = items

        return self.em.save('Item', i)
开发者ID:iamcm,项目名称:shared,代码行数:13,代码来源:tests.py

示例3: get_items

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import title [as 别名]
    def get_items(soup):
        """
        接收 parase() 方法传递的 beautifulsoup 对象,得到包含着Item对象的列表
        :param soup: beautifulsoup 对象
        :return: 包含着Item对象的列表
        """
        ul_container = soup.select('.leftWrap.discovery_list')[0]  # 获取包含着所有物品的那个<ul>标签
        all_items = ul_container.select('li')
        items = []      # 一个装着Item对象的列表
        for item in all_items:  # 循环中,每一个item都代表<ul>标签下的一个<li>标签
            this_item = Item()  # 实例化一个新的Item对象
            this_item.articleid = item['articleid']  # 获取该<li>标签的 articleid 属性
            this_item.link = item.select_one('.picBox')['href']  # 获取链接
            this_item.title = item.select_one('.itemName').select_one('.black').text  # 获取这个商品的标题
            this_item.price = item.select_one('.itemName').select_one('.red').text  # 获取这个商品的价格
            this_item.date = item.select_one('.time').text

            items.append(this_item)     # 添加当前的Item对象到items列表
        return items
开发者ID:lancelotlee86,项目名称:smzdm_clawer,代码行数:21,代码来源:clawer.py

示例4: test_entity_to_json_safe_dict

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import title [as 别名]
    def test_entity_to_json_safe_dict(self):
        i = Item()
        i.title = 'Nested Item'
        self.save_entity(title='Test1', items = [i,i,i])

        item = self.em.find_one('Item', {'title':'Test1'})

        jsondict = self.em.entity_to_json_safe_dict(item)

        self.assertIsInstance(jsondict, dict)

        self.assertEqual(jsondict['title'], 'Test1')

        #test nested object are still available
        self.assertEqual(jsondict['items'][0]['title'], 'Nested Item')

        #shouldnt be able to json serialise a datetime
        self.assertRaises(TypeError, json.dumps, item) 

        #should be able to json serialise Item after entity_to_json_safe_dict call
        self.assertIsInstance(json.dumps(jsondict), str) 
开发者ID:iamcm,项目名称:shared,代码行数:23,代码来源:tests.py

示例5: save

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import title [as 别名]
 def save(cls, request: Request, *args, **kwargs):
     """ Метод для сохранения товара
     :param request:
     :param kwargs:
     :return:
     """
     if request.get("id", False):
         item = catalog.get_item(int(request.get("id")))
     else:
         item = Item()
     item.title = request.get("title")
     item.article = request.get("article")
     item.short = request.get("short")
     item.imgs = request.get("imgs", [])
     item.body = request.get("body", "")
     item.tags = request.get("tags", [])
     item.categories = request.get("categories", [])
     item.cost = int(request.get("cost", 0)) if str(request.get("cost")).isnumeric() else None
     item.discount = int(request.get("discount")) if str(request.get("discount")).isnumeric() else None
     item.quantity = int(request.get("quantity")) if str(request.get("quantity")).isnumeric() else None
     item.set_attributes(request.get("attributes", []))
     return {"item_id": item.save()}
开发者ID:ayurjev,项目名称:catalog-api,代码行数:24,代码来源:controllers.py

示例6: post

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import title [as 别名]
  def post(self):
    url = urlfetch.fetch(self.request.get('content'))
    doc = lxml.html.fromstring(url.content)

    for sku in doc.cssselect('span'):
      if sku.get('id') == 'displaySkuCode':
        item_id = sku.text

    registry_item = Item.get_by_id(item_id)
    if registry_item is None:
      registry_item = Item(id=item_id, parent=ndb.Key("Website", self.request.get('website')))

    for tag in doc.cssselect('title'):
      registry_item.title = tag.text.encode('utf-8')

    for img in doc.cssselect('link'):
      if img.get('rel') == 'image_src':
        registry_item.img = img.get('href')

    for price in doc.cssselect('div'):
      if price.get('class') == 'sale-price':
        for savings in price.cssselect('strong'):
          registry_item.sale = savings.text.encode('utf-8')
      if price.get('class') == 'reg-price':
        registry_item.price = price.text.encode('utf-8').replace("Reg.", "")
    
    registry_item.category = self.request.get('category')
    registry_item.for_who = self.request.get('for_who')
    registry_item.put()

    link = URL.get_by_id(item_id)
    if link is None:
      link = URL(id=item_id, parent=ndb.Key("Website", self.request.get('website')))
    link.url = self.request.get('content')
    link.last_scrape = datetime.datetime.now()
    link.put()

    self.redirect('/listings')
开发者ID:tonycorp,项目名称:marinaregistry,代码行数:40,代码来源:scraper.py


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