本文整理汇总了Python中quodlibet.util.library.get_scan_dirs函数的典型用法代码示例。如果您正苦于以下问题:Python get_scan_dirs函数的具体用法?Python get_scan_dirs怎么用?Python get_scan_dirs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_scan_dirs函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_basic
def test_basic(self):
self.failIf(get_scan_dirs())
if os.name == "nt":
set_scan_dirs([u"C:\\foo", u"D:\\bar", u""])
self.failUnlessEqual(get_scan_dirs(), [u"C:\\foo", u"D:\\bar"])
else:
set_scan_dirs(["foo", "bar", ""])
self.failUnlessEqual(get_scan_dirs(), ["foo", "bar"])
开发者ID:Muges,项目名称:quodlibet,代码行数:8,代码来源:test_util.py
示例2: enabled
def enabled(self):
if not self.running:
wm = WatchManager()
self.event_handler = LibraryEvent(app.library)
# Choose event types to watch for
# FIXME: watch for IN_CREATE or for some reason folder copies
# are missed, --nickb
FLAGS = ['IN_DELETE', 'IN_CLOSE_WRITE',# 'IN_MODIFY',
'IN_MOVED_FROM', 'IN_MOVED_TO', 'IN_CREATE']
mask = reduce(lambda x, s: x | EventsCodes.ALL_FLAGS[s], FLAGS, 0)
if self.USE_THREADS:
print_d("Using threaded notifier")
self.notifier = ThreadedNotifier(wm, self.event_handler)
# Daemonize to ensure thread dies on exit
self.notifier.daemon = True
self.notifier.start()
else:
self.notifier = Notifier(wm, self.event_handler, timeout=100)
GLib.timeout_add(1000, self.unthreaded_callback)
for path in get_scan_dirs():
print_d('Watching directory %s for %s' % (path, FLAGS))
# See https://github.com/seb-m/pyinotify/wiki/
# Frequently-Asked-Questions
wm.add_watch(path, mask, rec=True, auto_add=True)
self.running = True
开发者ID:MikeiLL,项目名称:quodlibet,代码行数:29,代码来源:auto_library_update.py
示例3: __init__
def __init__(self, library):
super(FileSystem, self).__init__()
sw = ScrolledWindow()
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.set_shadow_type(Gtk.ShadowType.IN)
dt = MainDirectoryTree(folders=get_scan_dirs())
targets = [("text/x-quodlibet-songs", Gtk.TargetFlags.SAME_APP,
self.TARGET_QL),
("text/uri-list", 0, self.TARGET_EXT)]
targets = [Gtk.TargetEntry.new(*t) for t in targets]
dt.drag_source_set(Gdk.ModifierType.BUTTON1_MASK,
targets, Gdk.DragAction.COPY)
dt.connect('drag-data-get', self.__drag_data_get)
sel = dt.get_selection()
sel.unselect_all()
connect_obj(sel, 'changed', copool.add, self.__songs_selected, dt)
sel.connect("changed", self._on_selection_changed)
dt.connect('row-activated', lambda *a: self.songs_activated())
sw.add(dt)
self.pack_start(sw, True, True, 0)
self.show_all()
开发者ID:LudoBike,项目名称:quodlibet,代码行数:25,代码来源:filesystem.py
示例4: get_init_select_dir
def get_init_select_dir():
scandirs = get_scan_dirs()
if scandirs and os.path.isdir(scandirs[-1]):
# start with last added directory
return scandirs[-1]
else:
return get_home_dir()
开发者ID:bernd-wechner,项目名称:quodlibet,代码行数:7,代码来源:scanbox.py
示例5: enabled
def enabled(self):
if not self.running:
wm = WatchManager()
self.event_handler = LibraryEvent(library=app.library)
FLAGS = ['IN_DELETE', 'IN_CLOSE_WRITE', # 'IN_MODIFY',
'IN_MOVED_FROM', 'IN_MOVED_TO', 'IN_CREATE']
masks = [EventsCodes.FLAG_COLLECTIONS['OP_FLAGS'][s]
for s in FLAGS]
mask = reduce(operator.or_, masks, 0)
if self.USE_THREADS:
print_d("Using threaded notifier")
self.notifier = ThreadedNotifier(wm, self.event_handler)
# Daemonize to ensure thread dies on exit
self.notifier.daemon = True
self.notifier.start()
else:
self.notifier = Notifier(wm, self.event_handler, timeout=100)
GLib.timeout_add(1000, self.unthreaded_callback)
for path in get_scan_dirs():
real_path = os.path.realpath(path)
print_d('Watching directory %s for %s (mask: %x)'
% (real_path, FLAGS, mask))
# See https://github.com/seb-m/pyinotify/wiki/
# Frequently-Asked-Questions
wm.add_watch(real_path, mask, rec=True, auto_add=True)
self.running = True
开发者ID:Muges,项目名称:quodlibet,代码行数:31,代码来源:auto_library_update.py
示例6: __init__
def __init__(self, parent, init_dir):
super(MusicFolderChooser, self).__init__(parent, _("Add Music"), init_dir)
cb = Gtk.CheckButton(_("Watch this folder for new songs"))
# enable if no folders are being watched
cb.set_active(not get_scan_dirs())
cb.show()
self.set_extra_widget(cb)
开发者ID:virtuald,项目名称:quodlibet,代码行数:8,代码来源:quodlibetwindow.py
示例7: __init__
def __init__(self):
super(ScanBox, self).__init__(spacing=6)
self.model = model = Gtk.ListStore(str)
view = RCMHintedTreeView(model=model)
view.set_fixed_height_mode(True)
view.set_headers_visible(False)
view.set_tooltip_text(_("Songs in the listed folders will be added "
"to the library during a library refresh"))
menu = Gtk.Menu()
remove_item = MenuItem(_("_Remove"), Icons.LIST_REMOVE)
menu.append(remove_item)
menu.show_all()
view.connect('popup-menu', self.__popup, menu)
connect_obj(remove_item, 'activate', self.__remove, view)
sw = Gtk.ScrolledWindow()
sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
sw.set_shadow_type(Gtk.ShadowType.IN)
sw.add(view)
sw.set_size_request(-1, max(sw.size_request().height, 80))
render = Gtk.CellRendererText()
render.set_property('ellipsize', Pango.EllipsizeMode.END)
def cdf(column, cell, model, iter, data):
row = model[iter]
cell.set_property('text', unexpand(row[0]))
column = Gtk.TreeViewColumn(None, render)
column.set_cell_data_func(render, cdf)
column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
view.append_column(column)
add = Button(_("_Add"), Icons.LIST_ADD)
add.connect("clicked", self.__add)
remove = Button(_("_Remove"), Icons.LIST_REMOVE)
selection = view.get_selection()
selection.set_mode(Gtk.SelectionMode.MULTIPLE)
selection.connect("changed", self.__select_changed, remove)
selection.emit("changed")
connect_obj(remove, "clicked", self.__remove, view)
vbox = Gtk.VBox(spacing=6)
vbox.pack_start(add, False, True, 0)
vbox.pack_start(remove, False, True, 0)
self.pack_start(sw, True, True, 0)
self.pack_start(vbox, False, True, 0)
paths = map(fsdecode, get_scan_dirs())
for path in paths:
model.append(row=[path])
for child in self.get_children():
child.show_all()
开发者ID:bernd-wechner,项目名称:quodlibet,代码行数:58,代码来源:scanbox.py
示例8: __configure_scan_dirs
def __configure_scan_dirs(self, library):
"""Get user to configure scan dirs, if none is set up"""
if not get_scan_dirs() and not len(library) and quodlibet.is_first_session("quodlibet"):
print_d("Couldn't find any scan dirs")
resp = ConfirmLibDirSetup(self).run()
if resp == ConfirmLibDirSetup.RESPONSE_SETUP:
prefs = PreferencesWindow(self)
prefs.set_page("library")
prefs.show()
开发者ID:virtuald,项目名称:quodlibet,代码行数:10,代码来源:quodlibetwindow.py
示例9: open_chooser
def open_chooser(self, action):
last_dir = self.last_dir
if not os.path.exists(last_dir):
last_dir = get_home_dir()
class MusicFolderChooser(FolderChooser):
def __init__(self, parent, init_dir):
super(MusicFolderChooser, self).__init__(
parent, _("Add Music"), init_dir)
cb = Gtk.CheckButton(_("Watch this folder for new songs"))
# enable if no folders are being watched
cb.set_active(not get_scan_dirs())
cb.show()
self.set_extra_widget(cb)
def run(self):
fns = super(MusicFolderChooser, self).run()
cb = self.get_extra_widget()
return fns, cb.get_active()
class MusicFileChooser(FileChooser):
def __init__(self, parent, init_dir):
super(MusicFileChooser, self).__init__(
parent, _("Add Music"), formats.filter, init_dir)
if action.get_name() == "AddFolders":
dialog = MusicFolderChooser(self, last_dir)
fns, do_watch = dialog.run()
dialog.destroy()
if fns:
fns = map(glib2fsnative, fns)
# scan them
self.last_dir = fns[0]
copool.add(self.__library.scan, fns, cofuncid="library",
funcid="library")
# add them as library scan directory
if do_watch:
dirs = get_scan_dirs()
for fn in fns:
if fn not in dirs:
dirs.append(fn)
set_scan_dirs(dirs)
else:
dialog = MusicFileChooser(self, last_dir)
fns = dialog.run()
dialog.destroy()
if fns:
fns = map(glib2fsnative, fns)
self.last_dir = os.path.dirname(fns[0])
for filename in map(os.path.realpath, fns):
self.__library.add_filename(filename)
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:53,代码来源:quodlibetwindow.py
示例10: get_init_select_dir
def get_init_select_dir():
"""Returns a path which might be a good starting point when browsing
for a path for library scanning.
Returns:
fsnative
"""
scandirs = get_scan_dirs()
if scandirs and os.path.isdir(scandirs[-1]):
# start with last added directory
return scandirs[-1]
else:
return get_home_dir()
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:14,代码来源:scanbox.py
示例11: __init__
def __init__(self, parent):
if self.is_not_unique():
return
super(PreferencesWindow, self).__init__()
self.current_scan_dirs = get_scan_dirs()
self.set_title(_("Preferences"))
self.set_resizable(False)
self.set_transient_for(qltk.get_top_parent(parent))
self.__notebook = notebook = qltk.Notebook()
for Page in [self.SongList, self.Browsers, self.Player,
self.Library, self.Tagging]:
page = Page()
page.show()
notebook.append_page(page)
page_name = config.get("memory", "prefs_page", "")
self.set_page(page_name)
def on_switch_page(notebook, page, page_num):
config.set("memory", "prefs_page", page.name)
notebook.connect("switch-page", on_switch_page)
close = Button(_("_Close"), Icons.WINDOW_CLOSE)
connect_obj(close, 'clicked', lambda x: x.destroy(), self)
button_box = Gtk.HButtonBox()
button_box.set_layout(Gtk.ButtonBoxStyle.END)
button_box.pack_start(close, True, True, 0)
self.use_header_bar()
if self.has_close_button():
self.set_border_width(0)
notebook.set_show_border(False)
self.add(notebook)
else:
self.set_border_width(12)
vbox = Gtk.VBox(spacing=12)
vbox.pack_start(notebook, True, True, 0)
vbox.pack_start(button_box, False, True, 0)
self.add(vbox)
connect_obj(self, 'destroy', PreferencesWindow.__destroy, self)
self.get_child().show_all()
开发者ID:faubiguy,项目名称:quodlibet,代码行数:45,代码来源:prefs.py
示例12: test_get_scan_dirs
def test_get_scan_dirs(self):
some_path = os.path.join(unexpand(get_home_dir()), "foo")
config.set('settings', 'scan', some_path)
assert expanduser(some_path) in get_scan_dirs()
assert all([isinstance(p, fsnative) for p in get_scan_dirs()])
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:6,代码来源:test_util_library.py
示例13: _get_ql_base_dir
def _get_ql_base_dir(cls):
dirs = get_scan_dirs()
return os.path.realpath(dirs[0]) if dirs else ""
开发者ID:kriskielce88,项目名称:xn--ls8h,代码行数:3,代码来源:base.py
示例14: __destroy
def __destroy(self):
config.save()
if self.current_scan_dirs != get_scan_dirs():
scan_library(app.library, force=False)
开发者ID:faubiguy,项目名称:quodlibet,代码行数:4,代码来源:prefs.py
示例15: __destroy
def __destroy(self):
config.save()
if self.current_scan_dirs != get_scan_dirs():
print_d("Library paths have changed, re-scanning...")
scan_library(app.library, force=False)
开发者ID:elfalem,项目名称:quodlibet,代码行数:5,代码来源:prefs.py
示例16: __destroy
def __destroy(self):
config.write(const.CONFIG)
if self.current_scan_dirs != get_scan_dirs():
scan_library(app.library, force=False)
开发者ID:brunob,项目名称:quodlibet,代码行数:4,代码来源:prefs.py
注:本文中的quodlibet.util.library.get_scan_dirs函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论