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

Python base.empty函数代码示例

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

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



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

示例1: __init__

    def __init__(self, weboob, backend, torrent, parent=None):
        super(MiniTorrent, self).__init__(parent)
        self.parent = parent
        self.ui = Ui_MiniTorrent()
        self.ui.setupUi(self)

        self.weboob = weboob
        self.backend = backend
        self.torrent = torrent
        self.ui.nameLabel.setText(torrent.name)
        if not empty(torrent.seeders) and not empty(torrent.leechers):
            self.ui.seedLeechLabel.setText('%s/%s' % (torrent.seeders, torrent.leechers))
        if not empty(torrent.size):
            self.ui.sizeLabel.setText(u'%s' % sizeof_fmt(torrent.size))
        self.ui.backendButton.setText(backend.name)
        minfo = self.weboob.repositories.get_module_info(backend.NAME)
        icon_path = self.weboob.repositories.get_module_icon_path(minfo)
        if icon_path:
            pixmap = QPixmapCache.find(icon_path)
            if not pixmap:
                pixmap = QPixmap(QImage(icon_path))
            self.ui.backendButton.setIcon(QIcon(pixmap))

        self.ui.newTabButton.clicked.connect(self.newTabPressed)
        self.ui.viewButton.clicked.connect(self.viewPressed)
开发者ID:laurentb,项目名称:weboob,代码行数:25,代码来源:minitorrent.py


示例2: __init__

    def __init__(self, subtitle, backend, parent=None):
        QFrame.__init__(self, parent)
        self.parent = parent
        self.backend = backend
        self.ui = Ui_Subtitle()
        self.ui.setupUi(self)

        self.connect(self.ui.downloadButton, SIGNAL("clicked()"), self.download)

        self.subtitle = subtitle
        self.ui.idEdit.setText(u'%[email protected]%s' % (subtitle.id, backend.name))
        self.ui.nameLabel.setText(u'%s' % subtitle.name)
        if not empty(subtitle.nb_cd):
            self.ui.nbcdLabel.setText(u'%s' % subtitle.nb_cd)
        else:
            self.ui.nbcdLabel.parent().hide()
        if not empty(subtitle.language):
            self.ui.langLabel.setText(u'%s' % subtitle.language)
        else:
            self.ui.langLabel.parent().hide()
        if not empty(subtitle.description):
            self.ui.descriptionPlain.setPlainText(u'%s' % subtitle.description)
        else:
            self.ui.descriptionPlain.parent().hide()
        if not empty(subtitle.url):
            self.ui.urlEdit.setText(u'%s' % subtitle.url)
        else:
            self.ui.downloadButton.setDisabled(True)
            self.ui.downloadButton.setText('Impossible to download this subtitle')

        self.ui.verticalLayout.setAlignment(Qt.AlignTop)
开发者ID:frankrousseau,项目名称:weboob,代码行数:31,代码来源:subtitle.py


示例3: get_description

 def get_description(self, obj):
     result = u''
     if not empty(obj.preparation_time):
         result += 'prep time: %smin' % obj.preparation_time
     if not empty(obj.short_description):
         result += 'description: %s\n' % obj.short_description
     return result.strip()
开发者ID:frankrousseau,项目名称:weboob,代码行数:7,代码来源:cookboob.py


示例4: format_obj

    def format_obj(self, obj, alias):
        result = u'%s%s - %s%s\n' % (self.BOLD, obj.category, obj.summary, self.NC)
        result += u'Date: %s\n' % obj.start_date.strftime('%A %d %B %Y')
        result += u'Hour: %s - %s\n' % (obj.start_date.strftime('%H:%M'), obj.end_date.strftime('%H:%M'))

        if hasattr(obj, 'location') and not empty(obj.location):
            result += u'Location: %s\n' % obj.location

        if hasattr(obj, 'city') and not empty(obj.city):
            result += u'City: %s\n' % obj.city

        if hasattr(obj, 'event_planner') and not empty(obj.event_planner):
            result += u'Event planner: %s\n' % obj.event_planner

        if hasattr(obj, 'booked_entries') and not empty(obj.booked_entries) and \
           hasattr(obj, 'max_entries') and not empty(obj.max_entries):
            result += u'Entry: %s/%s \n' % (obj.booked_entries, obj.max_entries)
        elif hasattr(obj, 'booked_entries') and not empty(obj.booked_entries):
            result += u'Entry: %s \n' % (obj.booked_entries)
        elif hasattr(obj, 'max_entries') and not empty(obj.max_entries):
            result += u'Max entries: %s \n' % (obj.max_entries)

        if hasattr(obj, 'description') and not empty(obj.description):
            result += u'Description:\n %s\n\n' % obj.description

        if hasattr(obj, 'price') and not empty(obj.price):
            result += u'Price: %i\n' % obj.price

        if hasattr(obj, 'url') and not empty(obj.url):
            result += u'url: %s\n' % obj.url

        return result
开发者ID:pombredanne,项目名称:weboob,代码行数:32,代码来源:boobcoming.py


示例5: get_accounts

    def get_accounts(self):
        """
        Fetch accounts data from Weboob.

        :param backend: The Weboob built backend to fetch data from.

        :returns: A list of dicts representing the available accounts.
        """
        results = []
        with self.backend:
            for account in list(self.backend.iter_accounts()):
                # The minimum dict keys for an account are :
                # 'id', 'label', 'balance' and 'type'
                # Retrieve extra information for the account.
                account = self.backend.fillobj(account, ['iban', 'currency'])

                iban = None
                if not empty(account.iban):
                    iban = account.iban
                currency = None
                if not empty(account.currency):
                    currency = unicode(account.currency)

                results.append({
                    'vendorAccountId': account.id,
                    'label': account.label,
                    'balance': account.balance,
                    'iban': iban,
                    'currency': currency,
                    'type': account.type,
                })

        return results
开发者ID:bnjbvr,项目名称:kresus,代码行数:33,代码来源:main.py


示例6: format_obj

    def format_obj(self, obj, alias):
        bank = obj.backend
        phones = ""
        contacts = []
        if not empty(obj.phone):
            phones += obj.phone
        if not empty(obj.mobile):
            if phones != "":
                phones += " or %s" % obj.mobile
            else:
                phones += obj.mobile
        if phones:
            contacts.append(phones)

        for attr in ('email', 'agency', 'address'):
            value = getattr(obj, attr)
            if not empty(value):
                contacts.append(value)

        if len(contacts) > 0:
            first_contact = contacts.pop(0)
        else:
            first_contact = ""

        result = u"  %s %s %s " % (self.colored('%-15s' % bank, 'yellow'),
                                   self.colored('%-30s' % obj.name, 'red'),
                                   self.colored("%-30s" % first_contact, 'green'))
        for contact in contacts:
            result += "\n %s %s" % ((" ") * 47, self.colored("%-25s" % contact, 'green'))

        return result
开发者ID:laurentb,项目名称:weboob,代码行数:31,代码来源:boobank.py


示例7: check_housing_lists

    def check_housing_lists(self, query):
        results = list(itertools.islice(
            self.backend.search_housings(query),
            20
        ))
        self.assertGreater(len(results), 0)

        for field in self.FIELDS_ANY_HOUSINGS_LIST:
            self.assertTrue(
                any(not empty(getattr(x, field)) for x in results),
                'Missing a "%s" field.' % field
            )

        for x in results:
            if 'type' in self.FIELDS_ALL_HOUSINGS_LIST:
                self.assertEqual(x.type, query.type)
            if 'advert_type' in self.FIELDS_ALL_HOUSINGS_LIST:
                self.assertIn(x.advert_type, query.advert_types)
            if 'house_type' in self.FIELDS_ALL_HOUSINGS_LIST:
                self.assertIn(x.house_type, query.house_types)
            for field in self.FIELDS_ALL_HOUSINGS_LIST:
                self.assertNotEmpty(x, field)
            if not empty(x.cost):
                self.assertNotEmpty(x, 'price_per_meter')
            for photo in x.photos:
                self.assertRegexpMatches(photo.url, r'^http(s?)://')

        return results
开发者ID:P4ncake,项目名称:weboob,代码行数:28,代码来源:housing_test.py


示例8: search_housings

    def search_housings(self, query, cities):
        self.update_header()

        data = {}
        data['rubrique'] = TYPES.get(query.type)
        data['prix_max'] = query.cost_max or None
        data['surface_min'] = query.area_min or None
        if len(cities) > 1:
            data['rayon'] = None
        else:
            data['rayon'] = 100
        data['CategorieMode'] = None
        data['CategorieMaison'] = None
        data['Kilometrage'] = None
        data['top'] = 50
        data['order_by'] = 5
        data['sort_order'] = 1
        data['lstNbPieces'] = [query.nb_rooms or 0]
        data['pageNumber'] = 1

        for city in cities:
            data['localisation'] = {}
            data['localisation']['localisationid'] = city.id
            data['localisation']['label'] = city.name
            data['localisation']['localisationType'] = 5
            data['localisationType'] = 5
            data['lstLocalisationId'] = str(city.id)

            for house_type in query.house_types:
                data['lstTbien'] = RET.get(house_type)

                for house in self.search_house.go(data=json.dumps(data)).iter_houses():
                    if (empty(query.cost_min) or house.cost >= query.cost_min) and \
                       (empty(query.area_max) or house.area <= query.area_max):
                        yield house
开发者ID:laurentb,项目名称:weboob,代码行数:35,代码来源:browser.py


示例9: gotThumbnail

 def gotThumbnail(self):
     if empty(self.movie.thumbnail_url) and self.movie.thumbnail_url != NotAvailable:
         self.backend.fill_movie(self.movie, ('thumbnail_url'))
     if not empty(self.movie.thumbnail_url):
         data = requests.get(self.movie.thumbnail_url).content
         img = QImage.fromData(data)
         self.ui.imageLabel.setPixmap(QPixmap.fromImage(img).scaledToHeight(100,Qt.SmoothTransformation))
开发者ID:laurentb,项目名称:weboob,代码行数:7,代码来源:minimovie.py


示例10: gotThumbnail

 def gotThumbnail(self):
     if empty(self.person.thumbnail_url) and self.person.thumbnail_url != NotAvailable:
         self.backend.fill_person(self.person, ('thumbnail_url'))
     if not empty(self.person.thumbnail_url):
         data = urllib.urlopen(self.person.thumbnail_url).read()
         img = QImage.fromData(data)
         self.ui.imageLabel.setPixmap(QPixmap.fromImage(img).scaledToHeight(100,Qt.SmoothTransformation))
开发者ID:ffourcot,项目名称:weboob,代码行数:7,代码来源:miniperson.py


示例11: _set_video_attrs

    def _set_video_attrs(self, video):
        new_video = video_info(YoutubeVideo.id2url(video.id))
        if not new_video:
            return

        for k, v in new_video.iter_fields():
            if not empty(v) and empty(getattr(video, k)):
                setattr(video, k, v)
开发者ID:P4ncake,项目名称:weboob,代码行数:8,代码来源:module.py


示例12: get_description

 def get_description(self, obj):
     result = u""
     if not empty(obj.start_date):
         result += u"\tDate: %s\n" % obj.start_date.strftime("%A %d %B %Y")
         result += u"\tHour: %s" % obj.start_date.strftime("%H:%M")
         if not empty(obj.end_date):
             result += " - %s" % obj.end_date.strftime("%H:%M")
         result += "\n"
     return result.strip("\n\t")
开发者ID:nojhan,项目名称:weboob-devel,代码行数:9,代码来源:boobcoming.py


示例13: get_title

 def get_title(self, obj):
     s = obj.type
     if hasattr(obj, 'price') and not empty(obj.price):
         s += u' %s %s' % (self.colored(u'—', 'cyan'), self.colored('%6.2f %s' % (obj.price, Currency.currency2txt(obj.currency)), 'green'))
     if hasattr(obj, 'late') and not empty(obj.late) and obj.late > datetime.time():
         s += u' %s %s' % (self.colored(u'—', 'cyan'), self.colored('Late: %s' % obj.late, 'red', 'bold'))
     if hasattr(obj, 'information') and not empty(obj.information) and obj.information.strip() != '':
         s += u' %s %s' % (self.colored(u'—', 'cyan'), self.colored(obj.information, 'red'))
     return s
开发者ID:P4ncake,项目名称:weboob,代码行数:9,代码来源:traveloob.py


示例14: get_description

 def get_description(self, obj):
     result = u''
     if not empty(obj.start_date):
         result += u'\tDate: %s\n' % obj.start_date.strftime('%A %d %B %Y')
         result += u'\tHour: %s' % obj.start_date.strftime('%H:%M')
         if not empty(obj.end_date):
             result += ' - %s' % obj.end_date.strftime('%H:%M')
         result += '\n'
     return result.strip('\n\t')
开发者ID:frankrousseau,项目名称:weboob,代码行数:9,代码来源:boobcoming.py


示例15: transfer_check_account_iban

 def transfer_check_account_iban(self, old, new):
     # Skip origin account iban check and force origin account iban
     if empty(new) or empty(old):
         self.logger.warning(
             'Origin account iban check (%s) is not possible because iban is currently not available',
             old,
         )
         return True
     return old == new
开发者ID:laurentb,项目名称:weboob,代码行数:9,代码来源:module.py


示例16: order

 def order(self):
     if not self.shouldSkip():
         order = Order(id=self.order_number())
         order.date = self.order_date()
         order.tax = Decimal(self.tax()) if not empty(self.tax()) else Decimal(0.00)
         order.discount = Decimal(self.discount()) if not empty(self.discount()) else Decimal(0.00)
         order.shipping = Decimal(self.shipping()) if not empty(self.shipping()) else Decimal(0.00)
         order.total = Decimal(self.grand_total()) if not empty(self.grand_total()) else Decimal(0.00)
         return order
开发者ID:ngrislain,项目名称:weboob,代码行数:9,代码来源:pages.py


示例17: format_obj

    def format_obj(self, obj, alias):
        result = u'BEGIN:VEVENT\r\n'

        utc_zone = tz.gettz('UTC')

        event_timezone = tz.gettz(obj.timezone)
        start_date = obj.start_date if not empty(obj.start_date) else datetime.now()
        if isinstance(start_date, datetime):
            start_date = start_date.replace(tzinfo=event_timezone)
            utc_start_date = start_date.astimezone(utc_zone)
            result += u'DTSTART:%s\r\n' % utc_start_date.strftime("%Y%m%dT%H%M%SZ")
        else:
            result += u'DTSTART:%s\r\n' % start_date.strftime("%Y%m%d")

        end_date = obj.end_date if not empty(obj.end_date) else datetime.combine(start_date, time.max)
        if isinstance(end_date, datetime):
            end_date = end_date.replace(tzinfo=event_timezone)
            utc_end_date = end_date.astimezone(utc_zone)
            result += u'DTEND:%s\r\n' % utc_end_date.strftime("%Y%m%dT%H%M%SZ")
        else:
            result += u'DTEND:%s\r\n' % end_date.strftime("%Y%m%d")

        result += u'SUMMARY:%s\r\n' % obj.summary
        result += u'UID:%s\r\n' % obj.id
        result += u'STATUS:%s\r\n' % obj.status

        location = ''
        if hasattr(obj, 'location') and not empty(obj.location):
            location += obj.location + ' '

        if hasattr(obj, 'city') and not empty(obj.city):
            location += obj.city + ' '

        if not empty(location):
            result += u'LOCATION:%s\r\n' % location

        if hasattr(obj, 'categories') and not empty(obj.categories):
            result += u'CATEGORIES:%s\r\n' % obj.categories

        if hasattr(obj, 'description') and not empty(obj.description):
            result += u'DESCRIPTION:%s\r\n' % obj.description.strip(' \t\n\r')\
                                                             .replace('\r', '')\
                                                             .replace('\n', r'\n')\
                                                             .replace(',', '\,')

        if hasattr(obj, 'transp') and not empty(obj.transp):
            result += u'TRANSP:%s\r\n' % obj.transp

        if hasattr(obj, 'sequence') and not empty(obj.sequence):
            result += u'SEQUENCE:%s\r\n' % obj.sequence

        if hasattr(obj, 'url') and not empty(obj.url):
            result += u'URL:%s\r\n' % obj.url

        result += u'END:VEVENT\r\n'
        return result
开发者ID:laurentb,项目名称:weboob,代码行数:56,代码来源:boobcoming.py


示例18: get_description

    def get_description(self, obj):
        if empty(obj.duration) and empty(obj.date):
            return None

        result = '%s' % (obj.duration or obj.date)
        if hasattr(obj, 'author') and not empty(obj.author):
            result += u' - %s' % obj.author
        if hasattr(obj, 'rating') and not empty(obj.rating):
            result += u' (%s/%s)' % (obj.rating, obj.rating_max)
        return result
开发者ID:dasimon,项目名称:weboob,代码行数:10,代码来源:videoob.py


示例19: format_obj

 def format_obj(self, obj, alias):
     result = u"%s%s%s\n" % (self.BOLD, obj.name, self.NC)
     result += "ID: %s\n" % obj.fullid
     result += "URL: %s\n" % obj.url
     if not empty(obj.language):
         result += "LANG: %s\n" % obj.language
     if not empty(obj.nb_cd):
         result += "NB CD: %s\n" % obj.nb_cd
     result += "\n%sDescription%s\n" % (self.BOLD, self.NC)
     result += "%s" % obj.description
     return result
开发者ID:pombredanne,项目名称:weboob,代码行数:11,代码来源:suboob.py


示例20: format_obj

    def format_obj(self, obj, alias):
        name = obj.name
        city = u""
        if not empty(obj.city):
            city = obj.city

        if not obj.sensors or (len(obj.sensors) == 0):
            result = u' %s %s %s \n' %\
                   (self.colored('%-27s' % name[:27], 'red'),
                    self.colored('%-10s' % obj.object[:10], 'yellow'),
                    self.colored('%-10s' % city[:10], 'yellow')
                    )
            result += u' %s \n' % self.colored('%-47s' % obj.fullid[:47], 'blue')
        else:
            first = True
            firstaddress = obj.sensors[0].address
            for sensor in obj.sensors:
                sensorname = sensor.name
                # This is a int value, do not display it as a float
                if not empty(sensor.lastvalue.level):
                    if int(sensor.lastvalue.level) == sensor.lastvalue.level:
                        lastvalue = "%d " % sensor.lastvalue.level
                    else:
                        lastvalue = "%r " % sensor.lastvalue.level
                    if not empty(sensor.unit):
                        lastvalue += "%s" % sensor.unit
                else:
                    lastvalue = u"? "
                if first:
                    result = u' %s %s %s ' %\
                             (self.colored('%-27s' % name[:27], 'red'),
                              self.colored('%-10s' % obj.object[:10], 'yellow'),
                              self.colored('%-10s' % city[:10], 'yellow'),
                              )
                    if not empty(firstaddress):
                        result += u'%s' % self.colored('%-33s' % sensor.address[:33], 'yellow')
                    result += u'\n'
                    result += u' %s' % self.colored('%-47s' % obj.fullid[:47], 'blue')
                    result += u'   %s %s\n' %\
                              (self.colored('%-20s' % sensorname[:20], 'magenta'),
                               self.colored('%-13s' % lastvalue[:13], 'red')
                               )
                    first = False
                else:
                    result += u'                                                   %s %s\n' %\
                              (self.colored('%-20s' % sensorname[:20], 'magenta'),
                               self.colored('%-13s' % lastvalue[:13], 'red')
                               )
                    if not empty(sensor.address) and sensor.address != firstaddress:
                        result += u'                                                   %s \n' %\
                                  self.colored('%-33s' % sensor.address[:33], 'yellow')

        return result
开发者ID:P4ncake,项目名称:weboob,代码行数:53,代码来源:boobsize.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python base.find_object函数代码示例发布时间:2022-05-26
下一篇:
Python bank.Transfer类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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