本文整理汇总了Python中softwarecenter.utils.utf8函数的典型用法代码示例。如果您正苦于以下问题:Python utf8函数的具体用法?Python utf8怎么用?Python utf8使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utf8函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: show_add_to_launcher_panel
def show_add_to_launcher_panel(self, backend, pkgname, appname, app, appdetails, trans_id, trans_type):
"""
if Unity is currently running, display a panel to allow the user
the choose whether to add a newly-installed application to the
launcher
"""
# TODO: handle local deb install case
# TODO: implement the list view case (once it is specified)
# only show the panel if unity is running and this is a package install
#
# we only show the prompt for apps with a desktop file
if not appdetails.desktop_file:
return
# do not add apps without a exec line (like wine, see #848437)
if (os.path.exists(appdetails.desktop_file) and
is_no_display_desktop_file(appdetails.desktop_file)):
return
self.action_bar.add_button(ActionButtons.CANCEL_ADD_TO_LAUNCHER,
_("Not Now"),
self.on_cancel_add_to_launcher,
pkgname)
self.action_bar.add_button(ActionButtons.ADD_TO_LAUNCHER,
_("Add to Launcher"),
self.on_add_to_launcher,
pkgname,
app,
appdetails,
trans_id)
self.action_bar.set_label(utf8(_("Add %s to the launcher?")) % utf8(app.name))
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:29,代码来源:softwarepane.py
示例2: __init__
def __init__(self, subcategory=None):
self.subcategory = subcategory
if subcategory:
# this is the set of recommendations for a given subcategory
cat_title = u"Recommended For You in %s" % (
subcategory.untranslated_name)
tr_title = utf8(_("Recommended For You in %s")) % utf8(
subcategory.name)
else:
# this is the full set of recommendations for e.g. the lobby view
cat_title = u"Recommended For You"
tr_title = _("Recommended For You")
super(RecommendedForYouCategory, self).__init__(
cat_title,
tr_title,
None,
xapian.Query(),
flags=['available-only', 'not-installed-only'],
item_limit=60)
self.recommender_agent = RecommenderAgent()
self.recommender_agent.connect(
"recommend-me", self._recommend_me_result)
self.recommender_agent.connect(
"error", self._recommender_agent_error)
self.recommender_agent.query_recommend_me()
开发者ID:thnguyn2,项目名称:ECE_527_MP,代码行数:25,代码来源:categories.py
示例3: _apply_exceptions
def _apply_exceptions(self):
super(SCAPurchasedApplicationParser, self)._apply_exceptions()
# WARNING: item.name needs to be different than
# the item.name in the DB otherwise the DB
# gets confused about (appname, pkgname) duplication
self.sca_application.name = utf8(_("%s (already purchased)")) % utf8(self.sca_application.name)
self.sca_application.channel = PURCHASED_NEEDS_REINSTALL_MAGIC_CHANNEL_NAME
开发者ID:nevyn-hira,项目名称:software-centre-fix,代码行数:7,代码来源:update.py
示例4: __init__
def __init__(self, db, doc=None, application=None):
""" Create a new AppDetails object. It can be created from
a xapian.Document or from a db.application.Application object
"""
GObject.GObject.__init__(self)
if not doc and not application:
raise ValueError("Need either document or application")
self._db = db
self._db.connect("reopen", self._on_db_reopen)
self._cache = self._db._aptcache
self._distro = softwarecenter.distro.get_distro()
self._history = None
# import here (instead of global) to avoid dbus dependency
# in update-software-center (that imports application, but
# never uses AppDetails) LP: #620011
from softwarecenter.backend.installbackend import get_install_backend
self._backend = get_install_backend()
# FIXME: why two error states ?
self._error = None
self._error_not_found = None
self._screenshot_list = []
# load application
self._app = application
if doc:
self._app = Application(self._db.get_appname(doc), self._db.get_pkgname(doc), "")
# substitute for apturl
if self._app.request:
self._app.request = self._app.request.replace("$distro", self._distro.get_codename())
# load pkg cache
self._pkg = None
if self._app.pkgname in self._cache and self._cache[self._app.pkgname].candidate:
self._pkg = self._cache[self._app.pkgname]
# load xapian document
self._doc = doc
if not self._doc:
try:
self._doc = self._db.get_xapian_document(self._app.appname, self._app.pkgname)
except IndexError:
# if there is no document and no apturl request,
# set error state
debfile_matches = re.findall(r"/", self._app.request)
channel_matches = re.findall(r"channel=[a-z,-]*", self._app.request)
section_matches = re.findall(r"section=[a-z]*", self._app.request)
if not self._pkg and not debfile_matches and not channel_matches and not section_matches:
self._error = _("Not found")
self._error_not_found = utf8(
_(
u"There isn\u2019t a "
u"software package called \u201c%s\u201D in your "
u"current software sources."
)
) % utf8(self.pkgname)
开发者ID:pombredanne,项目名称:shop,代码行数:57,代码来源:application.py
示例5: pkg_state
def pkg_state(self):
# puchase state
if self.pkgname in self._backend.pending_purchases:
return PkgStates.INSTALLING_PURCHASED
# via the pending transactions dict
if self.pkgname in self._backend.pending_transactions:
# FIXME: we don't handle upgrades yet
# if there is no self._pkg yet, that means this is a INSTALL
# from a previously not-enabled source (like a purchase)
if self._pkg and self._pkg.installed:
return PkgStates.REMOVING
else:
return PkgStates.INSTALLING
# if we have _pkg that means its either:
# - available for download (via sources.list)
# - locally installed
# - intalled and available for download
if self._pkg:
# Don't handle upgrades yet
#if self._pkg.installed and self._pkg._isUpgradable:
# return PkgStates.UPGRADABLE
if self._pkg.is_installed:
return PkgStates.INSTALLED
else:
return PkgStates.UNINSTALLED
# if we don't have a _pkg, then its either:
# - its in a unavailable repo
# - the repository information is outdated
# - the repository information is missing (/var/lib/apt/lists empty)
# - its a failure in our meta-data (e.g. typo in the pkgname in
# the metadata)
if not self._pkg:
if self.channelname:
if self._unavailable_channel():
return PkgStates.NEEDS_SOURCE
else:
self._error = _("Not found")
self._error_not_found = utf8(_(u"There isn\u2019t a software package called \u201c%s\u201D in your current software sources.")) % utf8(self.pkgname)
return PkgStates.NOT_FOUND
else:
if self.price:
return PkgStates.NEEDS_PURCHASE
if (self.purchase_date and
self._doc.get_value(XapianValues.ARCHIVE_DEB_LINE)):
return PkgStates.PURCHASED_BUT_REPO_MUST_BE_ENABLED
if self.component:
components = self.component.split('&')
for component in components:
if component and self._unavailable_component(component_to_check=component):
return PkgStates.NEEDS_SOURCE
self._error = _("Not found")
self._error_not_found = utf8(_(u"There isn\u2019t a software package called \u201c%s\u201D in your current software sources.")) % utf8(self.pkgname)
return PkgStates.NOT_FOUND
return PkgStates.UNKNOWN
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:56,代码来源:application.py
示例6: _apply_exceptions
def _apply_exceptions(self):
super(SCAPurchasedApplicationParser, self)._apply_exceptions()
# WARNING: item.name needs to be different than
# the item.name in the DB otherwise the DB
# gets confused about (appname, pkgname) duplication
self.sca_application.name = utf8(_("%s (already purchased)")) % utf8(
self.sca_application.name)
for attr_name in ('license_key', 'license_key_path'):
attr = getattr(self.sca_subscription, attr_name, self.NOT_DEFINED)
if attr is self.NOT_DEFINED:
setattr(self.sca_subscription, attr_name, None)
开发者ID:pombredanne,项目名称:shop,代码行数:11,代码来源:update.py
示例7: __init__
def __init__(self, catview, subcategory):
RecommendationsPanel.__init__(self, catview)
self.subcategory = subcategory
if self.subcategory:
self.set_header_label(GObject.markup_escape_text(utf8(
_("Recommended For You in %s")) % utf8(self.subcategory.name)))
self.recommended_for_you_content = None
if self.recommender_agent.is_opted_in():
self._update_recommended_for_you_content()
else:
self._hide_recommended_for_you_panel()
开发者ID:thnguyn2,项目名称:ECE_527_MP,代码行数:11,代码来源:recommendations.py
示例8: __init__
def __init__(self, db, properties_helper, subcategory):
RecommendationsPanel.__init__(self)
self.db = db
self.properties_helper = properties_helper
self.subcategory = subcategory
if self.subcategory:
self.set_header_label(GLib.markup_escape_text(utf8(
_("Recommended For You in %s")) % utf8(self.subcategory.name)))
self.recommended_for_you_content = None
if self.recommender_agent.is_opted_in():
self._update_recommended_for_you_content()
else:
self.hide()
开发者ID:mortenpi,项目名称:ubuntu-software-center,代码行数:13,代码来源:recommendations.py
示例9: error
def error(self):
if self._error_not_found:
return self._error_not_found
elif self._error:
return self._error
# this may have changed since we inited the appdetails
elif self.pkg_state == PkgStates.NOT_FOUND:
self._error = _("Not found")
self._error_not_found = utf8(
_(u"There isn\u2019t a software "
u"package called \u201c%s\u201D in your current software "
u"sources.")) % utf8(self.pkgname)
return self._error_not_found
开发者ID:fossasia,项目名称:x-mario-center,代码行数:13,代码来源:application.py
示例10: warning
def warning(self):
# FIXME: use more concise warnings
if self._deb:
deb_state = self._deb.compare_to_version_in_cache(use_installed=False)
if deb_state == DebPackage.VERSION_NONE:
return utf8(_("Only install this file if you trust the origin."))
elif (not self._cache[self.pkgname].installed and
self._cache[self.pkgname].candidate and
self._cache[self.pkgname].candidate.downloadable):
if deb_state == DebPackage.VERSION_OUTDATED:
return utf8(_("Please install \"%s\" via your normal software channels. Only install this file if you trust the origin.")) % utf8(self.name)
elif deb_state == DebPackage.VERSION_SAME:
return utf8(_("Please install \"%s\" via your normal software channels. Only install this file if you trust the origin.")) % utf8(self.name)
elif deb_state == DebPackage.VERSION_NEWER:
return utf8(_("An older version of \"%s\" is available in your normal software channels. Only install this file if you trust the origin.")) % utf8(self.name)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:15,代码来源:debfile.py
示例11: __init__
def __init__(self, db, doc=None, application=None):
super(AppDetailsDebFile, self).__init__(db, doc, application)
if doc:
raise ValueError("doc must be None for deb files")
try:
# for some reason Cache() is much faster than "self._cache._cache"
# on startup
with ExecutionTime("create DebPackage"):
self._deb = DebPackage(self._app.request, Cache())
except:
self._deb = None
self._pkg = None
if not os.path.exists(self._app.request):
self._error = _("Not found")
self._error_not_found = utf8(_(u"The file \u201c%s\u201d does not exist.")) % utf8(self._app.request)
else:
mimetype = guess_type(self._app.request)
if mimetype[0] != "application/x-debian-package":
self._error = _("Not found")
self._error_not_found = utf8(_(u"The file \u201c%s\u201d is not a software package.")) % utf8(self._app.request)
else:
# deb files which are corrupt
self._error = _("Internal Error")
self._error_not_found = utf8(_(u"The file \u201c%s\u201d could not be opened.")) % utf8(self._app.request)
return
if self.pkgname and self.pkgname != self._app.pkgname:
# this happens when the deb file has a quirky file name
self._app.pkgname = self.pkgname
# load pkg cache
self._pkg = None
if (self._app.pkgname in self._cache and
self._cache[self._app.pkgname].candidate):
self._pkg = self._cache[self._app.pkgname]
# load xapian document
self._doc = None
try:
self._doc = self._db.get_xapian_document(
self._app.appname, self._app.pkgname)
except:
pass
# check deb and set failure state on error
with ExecutionTime("AppDetailsDebFile._deb.check()"):
if not self._deb.check():
self._error = self._deb._failure_string
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:48,代码来源:debfile.py
示例12: get_removal_warning_text
def get_removal_warning_text(self, cache, pkg, appname, depends):
primary = _("To remove %s, these items must be removed "
"as well:") % utf8(appname)
button_text = _("Remove All")
# alter it if an important meta-package is affected
for m in self.IMPORTANT_METAPACKAGES:
if m in depends:
primary = _("%s is a core item in Ubuntu. "
"Removing it may cause future upgrades "
"to be incomplete. Are you sure you want to "
"continue?") % appname
button_text = _("Remove Anyway")
depends = []
break
# alter it if a meta-package is affected
for m in depends:
if cache[m].section == "metapackages":
primary = _("If you uninstall %s, future updates will not "
"include new items in <b>%s</b> set. "
"Are you sure you want to continue?") % (
appname, cache[m].installed.summary)
button_text = _("Remove Anyway")
depends = []
break
return (primary, button_text)
开发者ID:pombredanne,项目名称:shop,代码行数:28,代码来源:ubuntu.py
示例13: _get_params
def _get_params(self):
p = {}
if self.help_text:
p['help_text'] = utf8(self.help_text)
if self._window_id:
p['window_id'] = self._window_id
return p
开发者ID:cs2c,项目名称:AppStream,代码行数:7,代码来源:login_sso.py
示例14: __str__
def __str__(self):
s = utf8('%s %s "%s" %s %s') % \
(self.category,
self.subcategory,
self.search_term,
self.application,
self.channel)
return s
开发者ID:cs2c,项目名称:AppStream,代码行数:8,代码来源:softwarepane.py
示例15: test_hardware_requirements_label_utf8
def test_hardware_requirements_label_utf8(self, mock_get_hw):
magic_marker = u" \u1234 GPS"
mock_get_hw.return_value = utf8(magic_marker)
label = HardwareRequirementsLabel()
label.set_hardware_requirement('hardware::gps', 'yes')
self.assertEqual(
label.get_label(),
u"%s%s" % (HardwareRequirementsLabel.SUPPORTED_SYM["yes"],
magic_marker))
开发者ID:gusDuarte,项目名称:software-center-5.2,代码行数:9,代码来源:test_widgets.py
示例16: test_get_hw_missing_long_description
def test_get_hw_missing_long_description(self):
s = get_hw_missing_long_description(
{ "hardware::input:keyboard": "yes",
OPENGL_DRIVER_BLACKLIST_TAG + "intel": "no",
})
self.assertEqual(s,
utf8(u'This software does not work with the '
u'\u201cintel\u201D graphics driver this '
u'computer is using.'))
开发者ID:feiying,项目名称:AppStream,代码行数:9,代码来源:test_hw.py
示例17: add_from_purchased_but_needs_reinstall_data
def add_from_purchased_but_needs_reinstall_data(purchased_but_may_need_reinstall_list, db, cache):
"""Add application that have been purchased but may require a reinstall
This adds a inmemory database to the main db with the special
PURCHASED_NEEDS_REINSTALL_MAGIC_CHANNEL_NAME channel prefix
:return: a xapian query to get all the apps that need reinstall
"""
# magic
db_purchased = xapian.inmemory_open()
# go over the items we have
for item in purchased_but_may_need_reinstall_list:
# FIXME: what to do with duplicated entries? we will end
# up with two xapian.Document, one for the for-pay
# and one for the availalbe one from s-c-agent
#try:
# db.get_xapian_document(item.name,
# item.package_name)
#except IndexError:
# # item is not in the xapian db
# pass
#else:
# # ignore items we already have in the db, ignore
# continue
# index the item
try:
# we fake a channel here
item.channel = PURCHASED_NEEDS_REINSTALL_MAGIC_CHANNEL_NAME
# and empty category to make the parser happy
item.categories = ""
# WARNING: item.name needs to be different than
# the item.name in the DB otherwise the DB
# gets confused about (appname, pkgname) duplication
item.name = utf8(_("%s (already purchased)")) % utf8(item.name)
parser = SoftwareCenterAgentParser(item)
index_app_info_from_parser(parser, db_purchased, cache)
except Exception as e:
LOG.exception("error processing: %s " % e)
# add new in memory db to the main db
db.add_database(db_purchased)
# return a query
query = xapian.Query("AH"+PURCHASED_NEEDS_REINSTALL_MAGIC_CHANNEL_NAME)
return query
开发者ID:armikhael,项目名称:software-center,代码行数:43,代码来源:update.py
示例18: get_title_text
def get_title_text(self, term, category, state):
from softwarecenter.utils import utf8
def build_category_path():
if not category:
return ''
if not state.subcategory:
return category.name
plain_text = _("%(category_name)s → %(subcategory_name)s")
usable_text = unicode(plain_text, 'utf8').encode('utf8')
return usable_text % {'category_name': category.name,
'subcategory_name': state.subcategory.name}
if not category:
sub = utf8(_(u"No items match “%s”")) % term
else:
sub = utf8(_(u"No items in %s match “%s”"))
sub = sub % (build_category_path(), term)
return self.HEADER_MARKUP % GLib.markup_escape_text(sub)
开发者ID:pombredanne,项目名称:shop,代码行数:20,代码来源:searchaid.py
示例19: get_install_warning_text
def get_install_warning_text(self, cache, pkg, appname, depends):
primary = utf8(_("To install %s, these items must be removed:")) % utf8(appname)
button_text = _("Install Anyway")
# alter it if a meta-package is affected
for m in depends:
if cache[m].section == "metapackages":
primary = utf8(
_(
"If you install %s, future updates will not "
"include new items in <b>%s</b> set. "
"Are you sure you want to continue?"
)
) % (utf8(appname), cache[m].installed.summary)
button_text = _("Install Anyway")
depends = []
break
# alter it if an important meta-package is affected
for m in self.IMPORTANT_METAPACKAGES:
if m in depends:
primary = utf8(
_(
"Installing %s may cause core applications "
"to be removed. Are you sure you want to "
"continue?"
)
) % utf8(appname)
button_text = _("Install Anyway")
depends = None
break
return (primary, button_text)
开发者ID:feiying,项目名称:AppStream,代码行数:32,代码来源:__init__.py
示例20: _whom_when_markup
def _whom_when_markup(self, person, displayname, cur_t):
nice_date = get_nice_date_string(cur_t)
#dt = datetime.datetime.utcnow() - cur_t
# prefer displayname if available
correct_name = displayname or person
if person == self.logged_in_person:
m = '%s (%s), %s' % (
GLib.markup_escape_text(utf8(correct_name)),
# TRANSLATORS: displayed in a review after the persons name,
# e.g. "Jane Smith (that's you), 2011-02-11"
utf8(_(u"that\u2019s you")),
GLib.markup_escape_text(utf8(nice_date)))
else:
try:
m = '%s, %s' % (
GLib.markup_escape_text(correct_name.encode("utf-8")),
GLib.markup_escape_text(nice_date))
except Exception:
LOG.exception("_who_when_markup failed")
m = "Error parsing name"
return m
开发者ID:pombredanne,项目名称:shop,代码行数:24,代码来源:reviews.py
注:本文中的softwarecenter.utils.utf8函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论