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