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


Python util.escape函数代码示例

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


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

示例1: _album

    def _album(self, song, box):
        if "album" not in song: return
        w = Label("")
        text = []
        text.append("<i>%s</i>" % util.escape(song.comma("album")))
        if "date" in song:
            text[-1] += " (%s)" % util.escape(song.comma("date"))
        secondary = []
        if "discnumber" in song:
            secondary.append(_("Disc %s") % song["discnumber"])
        if "discsubtitle" in song:
            secondary.append("<i>%s</i>" %
                             util.escape(song.comma("discsubtitle")))
        if "tracknumber" in song:
            secondary.append(_("Track %s") % song["tracknumber"])
        if secondary: text.append(" - ".join(secondary))

        if "organization" in song or "labelid" in song:
            t = util.escape(song.comma("~organization~labelid"))
            text.append(t)

        if "producer" in song:
            text.append("Produced by %s" %(
                util.escape(song.comma("producer"))))

        w.set_markup("\n".join(text))
        w.set_ellipsize(pango.ELLIPSIZE_END)
        hb = gtk.HBox(spacing=12)

        cover = CoverImage(song=song)
        if cover: hb.pack_start(cover, expand=False)
        else: cover.destroy()

        hb.pack_start(w)
        box.pack_start(Frame(tag("album"), hb), expand=False, fill=False)
开发者ID:silkecho,项目名称:glowing-silk,代码行数:35,代码来源:information.py

示例2: _title

 def _title(self, songs, box):
     song = songs[0]
     self.title = text = song["album"]
     markup = "<i>%s</i>" % util.escape(text)
     if "date" in song:
         markup += " <small>(%s)</small>" % util.escape(song("~year"))
     box.pack_start(TitleLabel(markup, is_markup=True), False, False, 0)
开发者ID:LudoBike,项目名称:quodlibet,代码行数:7,代码来源:information.py

示例3: website

    def website(self):
        """Look for a URL in the audio metadata, or a Google search
        if no URL can be found."""

        if "website" in self:
            return self.list("website")[0]
        for cont in self.list("contact") + self.list("comment"):
            c = cont.lower()
            if (c.startswith("http://") or c.startswith("https://") or
                    c.startswith("www.")):
                return cont
            elif c.startswith("//www."):
                return "http:" + cont
        else:
            text = "http://www.google.com/search?q="
            esc = lambda c: ord(c) > 127 and '%%%x' % ord(c) or c
            if "labelid" in self:
                text += ''.join(map(esc, self["labelid"]))
            else:
                artist = util.escape("+".join(self("artist").split()))
                album = util.escape("+".join(self("album").split()))
                artist = encode(artist)
                album = encode(album)
                artist = "%22" + ''.join(map(esc, artist)) + "%22"
                album = "%22" + ''.join(map(esc, album)) + "%22"
                text += artist + "+" + album
            text += "&ie=UTF8"
            return text
开发者ID:vrasidas,项目名称:quodlibet,代码行数:28,代码来源:_audio.py

示例4: cell_data

 def cell_data(col, render, model, iter):
     device = model[iter][0]
     if device.is_connected():
         render.markup = "<b>%s</b>" % util.escape(device['name'])
     else:
         render.markup = util.escape(device['name'])
     render.set_property('markup', render.markup)
开发者ID:silkecho,项目名称:glowing-silk,代码行数:7,代码来源:media.py

示例5: __save_files

 def __save_files(self, parent, model, library):
     win = WritingWindow(parent, len(model))
     was_changed = []
     for row in model:
         song = row[0]
         track = row[2]
         if song.get("tracknumber") == track:
             win.step()
             continue
         if not song.valid() and not qltk.ConfirmAction(
             win, _("Tag may not be accurate"),
             _("<b>%s</b> changed while the program was running. "
               "Saving without refreshing your library may "
               "overwrite other changes to the song.\n\n"
               "Save this song anyway?") %(
             util.escape(util.fsdecode(song("~basename"))))
             ).run():
             break
         song["tracknumber"] = track
         try: song.write()
         except:
             util.print_exc()
             qltk.ErrorMessage(
                 win, _("Unable to save song"),
                 _("Saving <b>%s</b> failed. The file may be "
                   "read-only, corrupted, or you do not have "
                   "permission to edit it.")%(
                 util.escape(util.fsdecode(song('~basename'))))).run()
             library.reload(song, changed=was_changed)
             break
         was_changed.append(song)
         if win.step(): break
     library.changed(was_changed)
     win.destroy()
开发者ID:silkecho,项目名称:glowing-silk,代码行数:34,代码来源:tracknumbers.py

示例6: _description

 def _description(self, songs, box):
     text = []
     cur_disc = songs[0]("~#disc", 1) - 1
     cur_part = None
     cur_track = songs[0]("~#track", 1) - 1
     for song in songs:
         track = song("~#track", 0)
         disc = song("~#disc", 0)
         part = song.get("part")
         if disc != cur_disc:
             if cur_disc:
                 text.append("")
             cur_track = song("~#track", 1) - 1
             cur_part = None
             cur_disc = disc
             if disc:
                 text.append("%s" % (_("Disc %s") % disc))
         if part != cur_part:
             ts = "    " * bool(disc)
             cur_part = part
             if part:
                 text.append("%s%s" % (ts, util.escape(part)))
         cur_track += 1
         ts = "    " * (bool(disc) + bool(part))
         while cur_track < track:
             text.append("{ts}{cur: >2}. {text}".format(
                 ts=ts, cur=cur_track, text=_("Track unavailable")))
             cur_track += 1
         markup = util.escape(song.comma("~title~version"))
         text.append("{ts}{cur: >2}. <i>{text}</i>".format(
                 ts=ts, cur=track, text=markup))
     l = Label(markup="\n".join(text), ellipsize=True)
     box.pack_start(Frame(_("Track List"), l), False, False, 0)
开发者ID:elfalem,项目名称:quodlibet,代码行数:33,代码来源:information.py

示例7: _description

 def _description(self, songs, box):
     text = []
     cur_disc = songs[0]("~#disc", 1) - 1
     cur_part = None
     cur_track = songs[0]("~#track", 1) - 1
     for song in songs:
         track = song("~#track", 0)
         disc = song("~#disc", 0)
         part = song.get("part")
         if disc != cur_disc:
             if cur_disc:
                 text.append("")
             cur_track = song("~#track", 1) - 1
             cur_part = None
             cur_disc = disc
             if disc:
                 text.append("<b>%s</b>" % (_("Disc %s") % disc))
         if part != cur_part:
             ts = "    " * bool(disc)
             cur_part = part
             if part:
                 text.append("%s<b>%s</b>" % (ts, util.escape(part)))
         cur_track += 1
         ts = "    " * (bool(disc) + bool(part))
         while cur_track < track:
             text.append("%s<b>%d.</b> <i>%s</i>" % (
                 ts, cur_track, _("Track unavailable")))
             cur_track += 1
         text.append("%s<b>%d.</b> %s" % (
             ts, track, util.escape(song.comma("~title~version"))))
     l = Label()
     l.set_markup("\n".join(text))
     l.set_ellipsize(Pango.EllipsizeMode.END)
     box.pack_start(Frame(_("Track List"), l), False, False, 0)
开发者ID:urielz,项目名称:quodlibet,代码行数:34,代码来源:information.py

示例8: _album

    def _album(self, song, box):
        if "album" not in song:
            return
        text = ["<span size='x-large'><i>%s</i></span>"
                % util.escape(song.comma("album"))]
        secondary = []
        if "discnumber" in song:
            secondary.append(_("Disc %s") % song["discnumber"])
        if "discsubtitle" in song:
            secondary.append("<i>%s</i>" %
                             util.escape(song.comma("discsubtitle")))
        if "tracknumber" in song:
            secondary.append(_("Track %s") % song["tracknumber"])
        if secondary:
            text.append(" - ".join(secondary))

        if "date" in song:
            text.append(util.escape(song.comma("date")))

        if "organization" in song or "labelid" in song:
            t = util.escape(song.comma("~organization~labelid"))
            text.append(t)

        if "producer" in song:
            text.append(_("Produced by %s") % (
                util.escape(song.comma("producer"))))

        w = Label(markup="\n".join(text), ellipsize=True)
        hb = Gtk.HBox(spacing=12)

        hb.pack_start(w, True, True, 0)
        box.pack_start(Frame(tag("album"), hb), False, False, 0)

        cover = ReactiveCoverImage(song=song)
        hb.pack_start(cover, False, True, 0)
开发者ID:elfalem,项目名称:quodlibet,代码行数:35,代码来源:information.py

示例9: _additional

    def _additional(self, song, box):
        if "website" not in song and "comment" not in song:
            return
        data = []

        if "comment" in song:
            comments = song.list("comment")
            markups = ["<i>%s</i>" % c for c in comments]
            data.append(("comment", markups))

        if "website" in song:
            markups = ["<a href=\"%(url)s\">%(text)s</a>" %
                       {"text": util.escape(website),
                        "url": util.escape(website)}
                       for website in song.list("website")]
            data.append(("website", markups))

        table = Table(1)
        for i, (key, markups) in enumerate(data):
            title = readable(key, plural=len(markups) > 1)
            lab = Label(markup=util.capitalize(util.escape(title) + ":"))
            table.attach(lab, 0, 1, i, i + 1, xoptions=Gtk.AttachOptions.FILL)
            lab = Label(markup="\n".join(markups), ellipsize=True)
            table.attach(lab, 1, 2, i, i + 1)
        box.pack_start(Frame(_("Additional"), table), False, False, 0)
开发者ID:elfalem,项目名称:quodlibet,代码行数:25,代码来源:information.py

示例10: __init__

    def __init__(self, parent, device):
        super(DeviceProperties, self).__init__(
            title=_("Device Properties"),
            transient_for=qltk.get_top_parent(parent))

        self.add_icon_button(_("_Close"), Icons.WINDOW_CLOSE,
                             Gtk.ResponseType.CLOSE)
        self.set_default_size(400, -1)
        self.connect('response', self.__close)

        table = Gtk.Table()
        table.set_border_width(8)
        table.set_row_spacings(8)
        table.set_col_spacings(8)
        self.vbox.pack_start(table, False, True, 0)

        props = []

        props.append((_("Device:"), device.block_device, None))
        mountpoint = util.escape(
            device.mountpoint or ("<i>%s</i>" % _("Not mounted")))
        props.append((_("Mount point:"), mountpoint, None))

        props.append((None, None, None))

        entry = Gtk.Entry()
        entry.set_text(device['name'])
        props.append((_("_Name:"), entry, 'name'))

        y = 0
        for title, value, key in props + device.Properties():
            if title is None:
                table.attach(Gtk.HSeparator(), 0, 2, y, y + 1)
            else:
                if key and isinstance(value, Gtk.CheckButton):
                    value.set_label(title)
                    value.set_use_underline(True)
                    value.connect('toggled', self.__changed, key, device)
                    table.attach(value, 0, 2, y, y + 1,
                                 xoptions=Gtk.AttachOptions.FILL)
                else:
                    label = Gtk.Label()
                    label.set_markup("<b>%s</b>" % util.escape(title))
                    label.set_alignment(0.0, 0.5)
                    table.attach(label, 0, 1, y, y + 1,
                                 xoptions=Gtk.AttachOptions.FILL)
                    if key and isinstance(value, Gtk.Widget):
                        widget = value
                        label.set_mnemonic_widget(widget)
                        label.set_use_underline(True)
                        widget.connect('changed', self.__changed, key, device)
                    else:
                        widget = Gtk.Label(label=value)
                        widget.set_use_markup(True)
                        widget.set_selectable(True)
                        widget.set_alignment(0.0, 0.5)
                    table.attach(widget, 1, 2, y, y + 1)
            y += 1
        self.get_child().show_all()
开发者ID:urielz,项目名称:quodlibet,代码行数:59,代码来源:media.py

示例11: _album

    def _album(self, songs, box):
        text = []

        discs = {}
        for song in songs:
            try:
                discs[song("~#disc")] = int(
                    song["tracknumber"].split("/")[1])
            except (AttributeError, ValueError, IndexError, KeyError):
                discs[song("~#disc")] = max([
                    song("~#track", discs.get(song("~#disc"), 0))])
        tracks = sum(discs.values())
        discs = len(discs)
        length = sum([song.get("~#length", 0) for song in songs])

        if tracks == 0 or tracks < len(songs):
            tracks = len(songs)

        parts = []
        if discs > 1:
            parts.append(
                ngettext("%d disc", "%d discs", discs) % discs)
        parts.append(
                ngettext("%d track", "%d tracks", tracks) % tracks)
        if tracks != len(songs):
            parts.append(ngettext("%d selected", "%d selected",
                len(songs)) % len(songs))

        text.append(", ".join(parts))
        text.append(util.format_time_preferred(length))

        if "location" in song:
            text.append(util.escape(song["location"]))
        if "organization" in song or "labelid" in song:
            t = util.escape(song.comma("~organization~labelid"))
            text.append(t)

        if "producer" in song:
            text.append(_("Produced by %s") % (
                util.escape(song.comma("producer"))))

        w = Label("")
        w.set_ellipsize(Pango.EllipsizeMode.END)
        w.set_markup("\n".join(text))
        hb = Gtk.HBox(spacing=12)

        cover = CoverImage()
        cover.set_property('no-show-all', True)
        hb.pack_start(cover, False, True, 0)

        def show_cover(cover, success):
            if success:
                cover.show()
            cover.disconnect(signal_id)
        signal_id = cover.connect('cover-visible', show_cover)
        cover.set_song(song)

        hb.pack_start(w, True, True, 0)
        box.pack_start(hb, False, False, 0)
开发者ID:urielz,项目名称:quodlibet,代码行数:59,代码来源:information.py

示例12: __init__

    def __init__(self, parent, player_error):
        add_full_stop = lambda s: s and (s.rstrip(".") + ".")
        description = add_full_stop(util.escape(player_error.short_desc))
        details = add_full_stop(util.escape(player_error.long_desc or ""))
        if details:
            description += " " + details

        super(PlaybackErrorDialog, self).__init__(parent, _("Playback Error"), description)
开发者ID:virtuald,项目名称:quodlibet,代码行数:8,代码来源:quodlibetwindow.py

示例13: cdf

 def cdf(column, cell, model, iter, data):
     row = model[iter]
     filename = fsn2text(unexpand(row[0]))
     function = row[1]
     line = row[2]
     cell.set_property(
         "markup", "<b>%s</b> line %d\n\t%s" % (
             util.escape(function), line, util.escape(filename)))
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:8,代码来源:debugwindow.py

示例14: __cdf

 def __cdf(self, column, cell, model, iter, data):
     row = model[iter]
     obj = row[0]
     obj_name = util.escape(obj.name)
     obj_description = util.escape(str(obj))
     markup = '<b>%s</b>\n%s' % (obj_name, obj_description)
     cell.markup = markup
     cell.set_property('markup', markup)
开发者ID:urielz,项目名称:quodlibet,代码行数:8,代码来源:data_editors.py

示例15: _title

 def _title(self, song, box):
     l = Label()
     text = "<big><b>%s</b></big>" % util.escape(song.comma("title"))
     if "version" in song:
         text += "\n" + util.escape(song.comma("version"))
     l.set_markup(text)
     l.set_ellipsize(Pango.EllipsizeMode.END)
     box.pack_start(l, False, False, 0)
     self.title = song.comma("title")
开发者ID:urielz,项目名称:quodlibet,代码行数:9,代码来源:information.py


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