本文整理汇总了Python中weboob.capabilities.base.empty函数的典型用法代码示例。如果您正苦于以下问题:Python empty函数的具体用法?Python empty怎么用?Python empty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了empty函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
示例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()
示例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
示例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
示例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
示例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
示例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
示例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))
示例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))
示例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)
示例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")
示例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
示例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')
示例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