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


Python path.get_home_dir函数代码示例

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


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

示例1: test_initial

    def test_initial(self):
        paths = ["/", get_home_dir(), "/usr/bin"]
        if os.name == "nt":
            paths = [u"C:\\", get_home_dir()]

        for path in paths:
            dirlist = DirectoryTree(path, folders=self.ROOTS)
            model, rows = dirlist.get_selection().get_selected_rows()
            selected = [model[row][0] for row in rows]
            dirlist.destroy()
            self.failUnlessEqual([path], selected)
开发者ID:LudoBike,项目名称:quodlibet,代码行数:11,代码来源:test_qltk_filesel.py

示例2: __get_themes

    def __get_themes(self):
        # deprecated, but there is no public replacement
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            theme_dir = Gtk.rc_get_theme_dir()

        theme_dirs = [theme_dir, os.path.join(get_home_dir(), ".themes")]

        themes = set()
        for theme_dir in theme_dirs:
            try:
                subdirs = os.listdir(theme_dir)
            except OSError:
                continue
            for dir_ in subdirs:
                gtk_dir = os.path.join(theme_dir, dir_, "gtk-3.0")
                if os.path.isdir(gtk_dir):
                    themes.add(dir_)

        try:
            resource_themes = Gio.resources_enumerate_children(
                "/org/gtk/libgtk/theme", 0)
        except GLib.GError:
            pass
        else:
            themes.update([t.rstrip("/") for t in resource_themes])

        return themes
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:28,代码来源:themeswitcher.py

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

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

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

示例6: __get_themes

    def __get_themes(self):
        # deprecated, but there is no public replacement
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            theme_dir = Gtk.rc_get_theme_dir()

        theme_dirs = [theme_dir, os.path.join(get_home_dir(), ".themes")]

        themes = set()
        for theme_dir in theme_dirs:
            try:
                subdirs = os.listdir(theme_dir)
            except OSError:
                continue
            for dir_ in subdirs:
                gtk_dir = os.path.join(theme_dir, dir_, "gtk-3.0")
                if os.path.isdir(gtk_dir):
                    themes.add(dir_)
        return themes
开发者ID:MikeiLL,项目名称:quodlibet,代码行数:19,代码来源:themeswitcher.py

示例7: get_favorites

def get_favorites():
    """A list of paths of commonly used folders (Desktop,..)

    Paths don't have to exist.
    """

    if os.name == "nt":
        return _get_win_favorites()
    else:
        paths = [get_home_dir()]

        xfg_user_dirs = xdg_get_user_dirs()
        for key in ["XDG_DESKTOP_DIR", "XDG_DOWNLOAD_DIR", "XDG_MUSIC_DIR"]:
            if key in xfg_user_dirs:
                path = xfg_user_dirs[key]
                if path not in paths:
                    paths.append(path)

        return paths
开发者ID:qwence,项目名称:quodlibet,代码行数:19,代码来源:filesel.py

示例8: __import

 def __import(self, activator, library):
     filt = lambda fn: fn.endswith(".pls") or fn.endswith(".m3u")
     from quodlibet.qltk.chooser import FileChooser
     chooser = FileChooser(self, _("Import Playlist"), filt, get_home_dir())
     files = chooser.run()
     chooser.destroy()
     for filename in files:
         if filename.endswith(".m3u"):
             playlist = parse_m3u(filename, library=library)
         elif filename.endswith(".pls"):
             playlist = parse_pls(filename, library=library)
         else:
             qltk.ErrorMessage(
                 qltk.get_top_parent(self),
                 _("Unable to import playlist"),
                 _("Quod Libet can only import playlists in the M3U "
                   "and PLS formats.")).run()
             return
         PlaylistsBrowser.changed(playlist)
         library.add(playlist)
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:20,代码来源:main.py

示例9: get_gtk_bookmarks

def get_gtk_bookmarks():
    """A list of paths from the GTK+ bookmarks.
    The paths don't have to exist.

    Returns:
        List[fsnative]
    """

    if os.name == "nt":
        return []

    path = os.path.join(get_home_dir(), ".gtk-bookmarks")
    folders = []
    try:
        with open(path, "rb") as f:
            folders = parse_gtk_bookmarks(f.read())
    except (EnvironmentError, ValueError):
        pass

    return folders
开发者ID:elfalem,项目名称:quodlibet,代码行数:20,代码来源:filesel.py

示例10: test_lyric_filename_search_order_priority

 def test_lyric_filename_search_order_priority(self):
     """test custom lyrics order priority"""
     with self.lyric_filename_test_setup() as ts:
         root2 = os.path.join(get_home_dir(), ".lyrics") # built-in default
         fp2 = os.path.join(root2, ts["artist"] + " - " +
                                   ts["title"] + ".lyric")
         p2 = os.path.dirname(fp2)
         mkdir(p2)
         with io.open(fp2, "w", encoding='utf-8') as f:
             f.write(u"")
         fp = os.path.join(ts.root, ts["artist"] + " - " +
                                    ts["title"] + ".lyric")
         with io.open(fp, "w", encoding='utf-8') as f:
             f.write(u"")
         mkdir(p2)
         search = ts.lyric_filename
         os.remove(fp2)
         os.rmdir(p2)
         os.remove(fp)
         self.assertEqual(search, fp)
开发者ID:LudoBike,项目名称:quodlibet,代码行数:20,代码来源:test_formats__audio.py

示例11: get_gtk_bookmarks

def get_gtk_bookmarks():
    """A list of paths from the GTK+ bookmarks.

    The paths don't have to exist.
    """

    if os.name == "nt":
        return []

    path = os.path.join(get_home_dir(), ".gtk-bookmarks")
    folders = []
    try:
        with open(path, "rb") as f:
            for line in f.readlines():
                parts = line.split()
                if not parts:
                    continue
                folder_url = parts[0]
                folders.append(urlparse.urlsplit(folder_url)[2])
    except EnvironmentError:
        pass

    return folders
开发者ID:qwence,项目名称:quodlibet,代码行数:23,代码来源:filesel.py

示例12: get_current_dir

def get_current_dir():
    """Returns the currently active chooser directory path.
    The path might not actually exist.

    Returns:
        fsnative
    """

    data = config.getbytes("memory", "chooser_dir", b"")
    try:
        path = bytes2fsn(data, "utf-8") or None
    except ValueError:
        path = None

    # the last user dir might not be there any more, try showing a parent
    # instead
    if path is not None:
        path = find_nearest_dir(path)

    if path is None:
        path = get_home_dir()

    return path
开发者ID:zsau,项目名称:quodlibet,代码行数:23,代码来源:chooser.py

示例13: test_get_home_dir

 def test_get_home_dir(self):
     self.assertTrue(isinstance(get_home_dir(), fsnative))
     self.assertTrue(os.path.isabs(get_home_dir()))
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:3,代码来源:test_util_path.py

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

示例15: test_get_exclude_dirs

    def test_get_exclude_dirs(self):
        some_path = os.path.join(unexpand(get_home_dir()), "foo")
        config.set('library', 'exclude', some_path)
        assert expanduser(some_path) in get_exclude_dirs()

        assert all([isinstance(p, fsnative) for p in get_exclude_dirs()])
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:6,代码来源:test_util_library.py


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