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


Python senf.fsn2text函数代码示例

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


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

示例1: test_main

 def test_main(self):
     self.assertEqual(decode_value("~#foo", 0.25), u"0.25")
     self.assertEqual(decode_value("~#foo", 4), u"4")
     self.assertEqual(decode_value("~#foo", "bar"), u"bar")
     self.assertTrue(isinstance(decode_value("~#foo", "bar"), text_type))
     path = fsnative(u"/foobar")
     self.assertEqual(decode_value("~filename", path), fsn2text(path))
开发者ID:Muges,项目名称:quodlibet,代码行数:7,代码来源:test_formats__audio.py

示例2: _init_gettext

def _init_gettext(no_translations=False):
    """Call before using gettext helpers"""

    if no_translations:
        language = u"C"
    else:
        language = config.gettext("settings", "language")
        if not language:
            language = None

    i18n.init(language)

    # Use the locale dir in ../build/share/locale if there is one
    base_dir = get_base_dir()
    localedir = os.path.dirname(base_dir)
    localedir = os.path.join(localedir, "build", "share", "locale")
    if not os.path.isdir(localedir) and os.name == "nt":
        # py2exe case
        localedir = os.path.join(
            base_dir, "..", "..", "share", "locale")

    i18n.register_translation("quodlibet", localedir)
    debug_text = environ.get("QUODLIBET_TEST_TRANS")
    if debug_text is not None:
        i18n.set_debug_text(fsn2text(debug_text))
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:25,代码来源:_init.py

示例3: print_exc

def print_exc(exc_info=None, context=None):
    """Prints the stack trace of the current exception or the passed one.
    Depending on the configuration will either print a short summary or the
    whole stacktrace.
    """

    if exc_info is None:
        exc_info = sys.exc_info()

    etype, value, tb = exc_info

    if const.DEBUG:
        string = u"".join(format_exception(etype, value, tb))
    else:
        # try to get a short error message pointing at the cause of
        # the exception
        text = u"".join(format_exception_only(etype, value))
        try:
            filename, lineno, name, line = extract_tb(tb)[-1]
        except IndexError:
            # no stack
            string = text
        else:
            string = u"%s:%s:%s: %s" % (
                fsn2text(path2fsn(os.path.basename(filename))),
                lineno, name, text)

    _print_message(string, context, False, "E", "red", "errors")
开发者ID:elfalem,项目名称:quodlibet,代码行数:28,代码来源:dprint.py

示例4: sort_key

def sort_key(song):
    """Sort by path so untagged albums have a good start order. Also
    take into account the directory in case it's split in different folders
    by medium.
    """

    return util.human_sort_key(fsn2text(song("~filename")))
开发者ID:zsau,项目名称:quodlibet,代码行数:7,代码来源:widgets.py

示例5: arg2text

def arg2text(arg):
    """Like fsn2text but is strict by default and raises CommandError"""

    try:
        return fsn2text(arg, strict=True)
    except ValueError as e:
        raise CommandError(e)
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:7,代码来源:commands.py

示例6: get_available_languages

def get_available_languages(domain):
    """Returns a list of available translations for a given gettext domain.

    Args:
        domain (str)
    Returns:
        List[text_type]
    """

    locale_dir = gettext.bindtextdomain(domain)
    if locale_dir is None:
        return []

    try:
        entries = os.listdir(locale_dir)
    except OSError:
        return []

    langs = [u"C"]
    for lang in entries:
        mo_path = os.path.join(
            locale_dir, lang, "LC_MESSAGES", "%s.mo" % domain)
        if os.path.exists(mo_path):
            langs.append(fsn2text(path2fsn(lang)))
    return langs
开发者ID:elfalem,项目名称:quodlibet,代码行数:25,代码来源:i18n.py

示例7: test_path

    def test_path(self):
        try:
            path = bytes2fsn(b"\xff\xff", "utf-8")
        except ValueError:
            return

        assert decode_value("~filename", path) == fsn2text(path)
开发者ID:Muges,项目名称:quodlibet,代码行数:7,代码来源:test_formats__audio.py

示例8: scan

    def scan(self, paths, exclude=[], cofuncid=None):

        def need_yield(last_yield=[0]):
            current = time.time()
            if abs(current - last_yield[0]) > 0.015:
                last_yield[0] = current
                return True
            return False

        def need_added(last_added=[0]):
            current = time.time()
            if abs(current - last_added[0]) > 1.0:
                last_added[0] = current
                return True
            return False

        # first scan each path for new files
        paths_to_load = []
        for scan_path in paths:
            print_d("Scanning %r." % scan_path)
            desc = _("Scanning %s") % (fsn2text(unexpand(scan_path)))
            with Task(_("Library"), desc) as task:
                if cofuncid:
                    task.copool(cofuncid)

                for real_path in iter_paths(scan_path, exclude=exclude):
                    if need_yield():
                        task.pulse()
                        yield
                    # skip unknown file extensions
                    if not formats.filter(real_path):
                        continue
                    # already loaded
                    if self.contains_filename(real_path):
                        continue
                    paths_to_load.append(real_path)

        yield

        # then (try to) load all new files
        with Task(_("Library"), _("Loading files")) as task:
            if cofuncid:
                task.copool(cofuncid)

            added = []
            for real_path in task.gen(paths_to_load):
                item = self.add_filename(real_path, False)
                if item is not None:
                    added.append(item)
                    if len(added) > 100 or need_added():
                        self.add(added)
                        added = []
                        yield
                if added and need_yield():
                    yield
            if added:
                self.add(added)
                added = []
                yield True
开发者ID:LudoBike,项目名称:quodlibet,代码行数:59,代码来源:libraries.py

示例9: 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

示例10: __init__

    def __init__(self, parent, song):
        title = _("Unable to save song")

        fn_format = "<b>%s</b>" % util.escape(fsn2text(song("~basename")))
        description = _("Saving %(file-name)s failed. The file may be "
            "read-only, corrupted, or you do not have "
            "permission to edit it.") % {"file-name": fn_format}

        super(WriteFailedError, self).__init__(
            parent, title, description)
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:10,代码来源:_editutils.py

示例11: label_path

        def label_path(path):
            l = Gtk.Label(label="<a href='%s'>%s</a>" % (
                            fsn2uri(path), escape(fsn2text(unexpand(path)))),
                          use_markup=True,
                          ellipsize=Pango.EllipsizeMode.MIDDLE,
                          xalign=0,
                          selectable=True)

            l.connect("activate-link", show_uri)
            return l
开发者ID:LudoBike,项目名称:quodlibet,代码行数:10,代码来源:appinfo.py

示例12: _execute

    def _execute(self, options, args):
        if len(args) < 3:
            raise CommandError(_("Not enough arguments"))

        tag = fsn2text(args[0])
        value = fsn2text(args[1])
        paths = args[2:]

        songs = []
        for path in paths:
            song = self.load_song(path)

            if not song.can_change(tag):
                raise CommandError(_("Can not set %r") % tag)

            self.log("Add %r to %r" % (value, tag))
            song.add(tag, value)
            songs.append(song)

        self.save_songs(songs)
开发者ID:LudoBike,项目名称:quodlibet,代码行数:20,代码来源:commands.py

示例13: __init__

    def __init__(self, parent, path):
        title = _("File exists")
        fn_format = "<b>%s</b>" % util.escape(fsn2text(path2fsn(path)))
        description = _("Replace %(file-name)s?") % {"file-name": fn_format}

        super(ConfirmFileReplace, self).__init__(
            parent, title, description, buttons=Gtk.ButtonsType.NONE)

        self.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL)
        self.add_icon_button(_("_Replace File"), Icons.DOCUMENT_SAVE,
                             self.RESPONSE_REPLACE)
        self.set_default_response(Gtk.ResponseType.CANCEL)
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:12,代码来源:msg.py

示例14: unescape_filename

def unescape_filename(s):
    """Unescape a string in a manner suitable for a filename.

    Args:
        filename (fsnative)
    Returns:
        text_type
    """

    assert isinstance(s, fsnative)

    return fsn2text(unquote(s))
开发者ID:elfalem,项目名称:quodlibet,代码行数:12,代码来源:path.py

示例15: __preview

    def __preview(self, pattern, songs):
        rows = []
        for song in songs:
            match = pattern.match(song)
            row = [fsn2text(song("~basename"))]
            for header in pattern.headers:
                row.append(match.get(header, u""))
            rows.append(row)

        headers = [_("File")] + pattern.headers
        nicks = ["file"] + pattern.headers
        print_table(rows, headers, nicks, nicks)
开发者ID:LudoBike,项目名称:quodlibet,代码行数:12,代码来源:commands.py


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