本文整理汇总了Python中quodlibet.util.path.fsdecode函数的典型用法代码示例。如果您正苦于以下问题:Python fsdecode函数的具体用法?Python fsdecode怎么用?Python fsdecode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fsdecode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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")))
开发者ID:bernd-wechner,项目名称:quodlibet,代码行数:7,代码来源:widgets.py
示例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))
开发者ID:pyromaniac2k,项目名称:quodlibet,代码行数:7,代码来源:test_formats__audio.py
示例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)))
开发者ID:bernd-wechner,项目名称:quodlibet,代码行数:8,代码来源:debugwindow.py
示例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)
开发者ID:bernd-wechner,项目名称:quodlibet,代码行数:10,代码来源:_editutils.py
示例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
开发者ID:kriskielce88,项目名称:xn--ls8h,代码行数:55,代码来源:libraries.py
示例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.")
开发者ID:SimonLarsen,项目名称:quodlibet,代码行数:55,代码来源:exfalso.py
示例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
开发者ID:kriskielce88,项目名称:xn--ls8h,代码行数:11,代码来源:_pattern.py
示例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)
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:11,代码来源:uri.py
示例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
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:11,代码来源:dbus_.py
示例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)
开发者ID:gbtami,项目名称:quodlibet,代码行数:12,代码来源:commands.py
示例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)
开发者ID:bernd-wechner,项目名称:quodlibet,代码行数:12,代码来源:msg.py
示例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
开发者ID:anweshknayak,项目名称:quodlibet,代码行数:22,代码来源:_match.py
示例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)
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:13,代码来源:msg.py
示例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)
开发者ID:SimonLarsen,项目名称:quodlibet,代码行数:13,代码来源:util.py
示例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)
开发者ID:vrasidas,项目名称:quodlibet,代码行数:14,代码来源:_audio.py
示例16: __init__
def __init__(self, filename):
with translate_errors():
with open(filename, "rb") as h:
head = h.read(46)
if len(head) != 46 or head[:27] != b"SNES-SPC700 Sound File Data":
raise IOError("Not a valid SNES-SPC700 file")
if getbyte(head, 35) == b"\x1a":
data = h.read(210)
if len(data) == 210:
self.update(parse_id666(data))
self.setdefault("title", fsdecode(os.path.basename(filename)[:-4]))
self.sanitize(filename)
开发者ID:faubiguy,项目名称:quodlibet,代码行数:14,代码来源:spc.py
示例17: _song_to_text
def _song_to_text(self, song):
# to text
lines = []
for key in sorted(song.realkeys(), key=sortkey):
for value in song.list(key):
lines.append(u"%s=%s" % (key, value))
lines += [
u"",
u"#" * 80,
u"# Lines that are empty or start with '#' will be ignored",
u"# File: %r" % fsdecode(song("~filename")),
]
return u"\n".join(lines)
开发者ID:gbtami,项目名称:quodlibet,代码行数:15,代码来源:commands.py
示例18: sort_by_func
def sort_by_func(tag):
"""Returns a fast sort function for a specific tag (or pattern).
Some keys are already in the sort cache, so we can use them."""
def artist_sort(song):
return song.sort_key[1][2]
if callable(tag):
return lambda song: human(tag(song))
elif tag == "artistsort":
return artist_sort
elif tag in FILESYSTEM_TAGS:
return lambda song: fsdecode(song(tag), note=False)
elif tag.startswith("~#") and "~" not in tag[2:]:
return lambda song: song(tag)
return lambda song: human(song(tag))
开发者ID:vrasidas,项目名称:quodlibet,代码行数:15,代码来源:_audio.py
示例19: __init__
def __init__(self, paths):
super(FileListExpander, self).__init__(label=_("Files:"))
self.set_resize_toplevel(True)
paths = [fsdecode(unexpand(p)) for p in paths]
lab = Gtk.Label(label="\n".join(paths))
lab.set_alignment(0.0, 0.0)
lab.set_selectable(True)
win = Gtk.ScrolledWindow()
win.add_with_viewport(Alignment(lab, border=6))
win.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
win.set_shadow_type(Gtk.ShadowType.ETCHED_OUT)
win.set_size_request(-1, 100)
self.add(win)
win.show_all()
开发者ID:kriskielce88,项目名称:xn--ls8h,代码行数:15,代码来源:delete.py
示例20: parse_pls
def parse_pls(filename, name="", library=None):
plname = fsdecode(os.path.basename(os.path.splitext(filename)[0]))
filenames = []
h = file(filename)
for line in h:
line = line.strip()
if not line.lower().startswith("file"):
continue
else:
try:
line = line[line.index("=") + 1 :].strip()
except ValueError:
pass
else:
filenames.append(line)
h.close()
return __parse_playlist(plname, filename, filenames, library)
开发者ID:SimonLarsen,项目名称:quodlibet,代码行数:18,代码来源:util.py
注:本文中的quodlibet.util.path.fsdecode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论