本文整理汇总了Python中quodlibet.util.path.fsdecode函数的典型用法代码示例。如果您正苦于以下问题:Python fsdecode函数的具体用法?Python fsdecode怎么用?Python fsdecode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fsdecode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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(path.fsdecode(song("~filename")))
示例2: 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"), unicode))
path = fsnative(u"/foobar")
self.assertEqual(decode_value("~filename", path), fsdecode(path))
示例3: cdf
def cdf(column, cell, model, iter, data):
row = model[iter]
filename = fsdecode(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)))
示例4: __init__
def __init__(self, parent, song):
title = _("Unable to save song")
fn_format = "<b>%s</b>" % util.escape(fsdecode(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)
示例5: scan
def scan(self, paths, exclude=[], cofuncid=None):
added = []
exclude = [expanduser(path) for path in exclude if path]
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
for fullpath in paths:
print_d("Scanning %r." % fullpath, self)
desc = _("Scanning %s") % (unexpand(fsdecode(fullpath)))
with Task(_("Library"), desc) as task:
if cofuncid:
task.copool(cofuncid)
fullpath = expanduser(fullpath)
if filter(fullpath.startswith, exclude):
continue
for path, dnames, fnames in os.walk(fullpath):
for filename in fnames:
fullfilename = os.path.join(path, filename)
if filter(fullfilename.startswith, exclude):
continue
if fullfilename not in self._contents:
fullfilename = os.path.realpath(fullfilename)
# skip unknown file extensions
if not formats.filter(fullfilename):
continue
if filter(fullfilename.startswith, exclude):
continue
if fullfilename not in self._contents:
item = self.add_filename(fullfilename, False)
if item is not None:
added.append(item)
if len(added) > 100 or need_added():
self.add(added)
added = []
task.pulse()
yield
if added and need_yield():
yield
if added:
self.add(added)
added = []
task.pulse()
yield True
示例6: main
def main(argv):
import quodlibet
from quodlibet.qltk import add_signal_watch, icons
add_signal_watch(app.quit)
opts = util.OptionParser("Ex Falso", const.VERSION, _("an audio tag editor"), "[%s]" % _("directory"))
# FIXME: support unicode on Windows, sys.argv isn't good enough
argv.append(os.path.abspath(fsnative(u".")))
opts, args = opts.parse(argv[1:])
args[0] = os.path.realpath(args[0])
config.init(os.path.join(quodlibet.get_user_dir(), "config"))
app.name = "Ex Falso"
app.id = "exfalso"
quodlibet.init(icon=icons.EXFALSO, name=app.name, proc_title=app.id)
import quodlibet.library
import quodlibet.player
app.library = quodlibet.library.init()
app.player = quodlibet.player.init_player("nullbe", app.librarian)
from quodlibet.qltk.songlist import PlaylistModel
app.player.setup(PlaylistModel(), None, 0)
pm = quodlibet.init_plugins()
pm.rescan()
from quodlibet.qltk.exfalsowindow import ExFalsoWindow
dir_ = args[0]
if os.name == "nt":
dir_ = fsdecode(dir_)
app.window = ExFalsoWindow(app.library, dir_)
app.window.init_plugins()
from quodlibet.util.cover import CoverManager
app.cover_manager = CoverManager()
app.cover_manager.init_plugins()
from quodlibet.qltk import session
session.init("exfalso")
quodlibet.enable_periodic_save(save_library=False)
quodlibet.main(app.window)
quodlibet.finish_first_session(app.id)
config.save()
print_d("Finished shutdown.")
示例7: comma
def comma(self, key):
value = self.__song.comma(key)
if isinstance(value, str):
value = fsdecode(value)
elif not isinstance(value, unicode):
if isinstance(value, float):
value = "%.2f" % value
value = unicode(value)
if self.__formatter:
return self.__formatter(key, value)
return value
示例8: filename
def filename(self):
"""a local filename equivalent to the URI"""
if self.scheme != "file":
raise ValueError("only the file scheme supports filenames")
elif self.netloc:
raise ValueError("only local files have filenames")
else:
if os.name == "nt":
return fsdecode(url2pathname(self.path))
else:
return url2pathname(self.path)
示例9: __dict
def __dict(self, song):
dict = {}
for key, value in (song or {}).items():
if not isinstance(value, basestring):
value = unicode(value)
elif isinstance(value, str):
value = fsdecode(value)
dict[key] = dbusutils.dbus_unicode_validate(value)
if song:
dict["~uri"] = song("~uri")
return dict
示例10: __preview
def __preview(self, pattern, songs):
rows = []
for song in songs:
match = pattern.match(song)
row = [fsdecode(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)
示例11: __init__
def __init__(self, parent, path):
title = _("File exists")
fn_format = "<b>%s</b>" % util.escape(fsdecode(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)
示例12: search
def search(self, data):
for name in self.__names:
val = data.get(name)
if val is None:
# filename is the only real entry that's a path
if name == "filename":
val = fsdecode(data.get("~filename", ""))
else:
val = data.get("~" + name, "")
if self.res.search(unicode(val)):
return True
for name in self.__intern:
if self.res.search(unicode(data(name))):
return True
for name in self.__fs:
if self.res.search(fsdecode(data(name))):
return True
return False
示例13: __init__
def __init__(self, parent, path):
title = _("File exists")
fn_format = "<b>%s</b>" % util.escape(fsdecode(path))
description = _("Replace %(file-name)s?") % {"file-name": fn_format}
super(ConfirmFileReplace, self).__init__(
parent, title, description, buttons=Gtk.ButtonsType.NONE)
self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
save_button = Button(_("_Replace File"), "document-save")
save_button.show()
self.add_action_widget(save_button, self.RESPONSE_REPLACE)
self.set_default_response(Gtk.ResponseType.CANCEL)
示例14: parse_m3u
def parse_m3u(filename, library=None):
plname = fsdecode(os.path.basename(os.path.splitext(filename)[0]))
filenames = []
with open(filename, "rb") as h:
for line in h:
line = line.strip()
if line.startswith("#"):
continue
else:
filenames.append(line)
return __parse_playlist(plname, filename, filenames, library)
示例15: decode_value
def decode_value(tag, value):
"""Returns a unicode representation of the passed value, based on
the type and the tag it originated from.
Not reversible.
"""
if isinstance(value, unicode):
return value
elif isinstance(value, float):
return u"%.2f" % value
elif tag in FILESYSTEM_TAGS:
return fsdecode(value)
return unicode(value)