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


Python path.mkdir函数代码示例

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


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

示例1: get_user_dir

def get_user_dir():
    """Place where QL saves its state, database, config etc."""

    if os.name == "nt":
        USERDIR = os.path.join(windows.get_appdata_dir(), "Quod Libet")
    elif is_osx():
        USERDIR = os.path.join(os.path.expanduser("~"), ".quodlibet")
    else:
        USERDIR = os.path.join(xdg_get_config_home(), "quodlibet")

        if not os.path.exists(USERDIR):
            tmp = os.path.join(os.path.expanduser("~"), ".quodlibet")
            if os.path.exists(tmp):
                USERDIR = tmp

    if 'QUODLIBET_USERDIR' in environ:
        USERDIR = environ['QUODLIBET_USERDIR']

    if build.BUILD_TYPE == u"windows-portable":
        USERDIR = os.path.normpath(os.path.join(
            os.path.dirname(path2fsn(sys.executable)), "..", "..", "config"))

    # XXX: users shouldn't assume the dir is there, but we currently do in
    # some places
    mkdir(USERDIR, 0o750)

    return USERDIR
开发者ID:zsau,项目名称:quodlibet,代码行数:27,代码来源:_main.py

示例2: dump_to_disk

def dump_to_disk(dump_dir, exc_info):
    """Writes a new error log file into 'dump_dir'

    Args:
        dump_dir (path-like)
        exc_info (tuple): sys.exc_info() result tuple
    """

    try:
        mkdir(dump_dir)
    except EnvironmentError:
        print_exc()
        return

    time_ = time.localtime()
    dump_path = os.path.join(
        dump_dir, time.strftime("Dump_%Y%m%d_%H%M%S.txt", time_))

    header = format_dump_header(exc_info).encode("utf-8")
    log = format_dump_log().encode("utf-8")

    try:
        with open(dump_path, "wb") as dump:
            dump.write(header)
            dump.write(log)
    except EnvironmentError:
        print_exc()
开发者ID:LudoBike,项目名称:quodlibet,代码行数:27,代码来源:logdump.py

示例3: init

def init(icon=None, proc_title=None, name=None):
    global quodlibet

    print_d("Entering quodlibet.init")

    _gtk_init()
    _gtk_icons_init(get_image_dir(), icon)
    _gst_init()
    _dbus_init()
    _init_debug()

    from gi.repository import GLib

    if proc_title:
        GLib.set_prgname(proc_title)
        set_process_title(proc_title)
        # Issue 736 - set after main loop has started (gtk seems to reset it)
        GLib.idle_add(set_process_title, proc_title)

    if name:
        GLib.set_application_name(name)

    mkdir(get_user_dir(), 0750)

    print_d("Finished initialization.")
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:25,代码来源:__init__.py

示例4: setUp

    def setUp(self):
        # Testing locally is VERY dangerous without this...
        self.assertTrue(_TEMP_DIR in PLAYLISTS or os.name == "nt",
                        msg="Failing, don't want to delete %s" % PLAYLISTS)
        try:
            shutil.rmtree(PLAYLISTS)
        except OSError:
            pass

        mkdir(PLAYLISTS)

        self.lib = quodlibet.browsers.playlists.library = SongLibrary()
        self.lib.librarian = SongLibrarian()
        all_songs = SONGS + [self.ANOTHER_SONG]
        for af in all_songs:
            af.sanitize()
        self.lib.add(all_songs)

        self.big = pl = FileBackedPlaylist.new(PLAYLISTS, "Big", self.lib)
        pl.extend(SONGS)
        pl.write()

        self.small = pl = FileBackedPlaylist.new(PLAYLISTS, "Small", self.lib)
        pl.extend([self.ANOTHER_SONG])
        pl.write()

        PlaylistsBrowser.init(self.lib)

        self.bar = PlaylistsBrowser(self.lib)
        self.bar.connect('songs-selected', self._expected)
        self.bar._select_playlist(self.bar.playlists()[0])
        self.expected = None
开发者ID:bossjones,项目名称:quodlibet,代码行数:32,代码来源:test_browsers_playlists.py

示例5: get_user_dir

def get_user_dir():
    """Place where QL saves its state, database, config etc."""

    if os.name == "nt":
        USERDIR = os.path.join(windows.get_appdate_dir(), "Quod Libet")
    else:
        USERDIR = os.path.join(os.path.expanduser("~"), ".quodlibet")

    if not PY2:
        USERDIR += "_py3"

    if 'QUODLIBET_USERDIR' in environ:
        USERDIR = environ['QUODLIBET_USERDIR']

    # XXX: Exec conf.py in this directory, used to override const globals
    # e.g. for setting USERDIR for the Windows portable version
    # Note: execfile doesn't handle unicode paths on windows, so encode.
    # (this doesn't use the old win api in case of str compared to os.*)
    _CONF_PATH = os.path.join(
        os.path.dirname(os.path.realpath(__file__)), "conf.py")
    if PY2:
        # FIXME: PY3PORT
        try:
            execfile(_CONF_PATH)
        except IOError:
            pass

    # XXX: users shouldn't assume the dir is there, but we currently do in
    # some places
    mkdir(USERDIR, 0o750)

    return USERDIR
开发者ID:bossjones,项目名称:quodlibet,代码行数:32,代码来源:__init__.py

示例6: write

    def write(self, filename):
        """Write config to filename.

        Can raise EnvironmentError
        """

        assert isinstance(filename, fsnative)

        mkdir(os.path.dirname(filename))

        # temporary set the new version for saving
        if self._version is not None:
            self.add_section("__config__")
            self.set("__config__", "version", self._version)
        try:
            with atomic_save(filename, "wb") as fileobj:
                if PY2:
                    self._config.write(fileobj)
                else:
                    temp = StringIO()
                    self._config.write(temp)
                    data = temp.getvalue().encode("utf-8", "surrogateescape")
                    fileobj.write(data)
        finally:
            if self._loaded_version is not None:
                self.set("__config__", "version", self._loaded_version)
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:26,代码来源:config.py

示例7: setUp

    def setUp(self):
        try:
            shutil.rmtree(PLAYLISTS)
        except OSError:
            pass

        mkdir(PLAYLISTS)

        self.lib = quodlibet.browsers.playlists.library = SongLibrary()
        self.lib.librarian = SongLibrarian()
        all_songs = SONGS + [self.ANOTHER_SONG]
        for af in all_songs:
            af.sanitize()
        self.lib.add(all_songs)

        pl = Playlist.new(PLAYLISTS, "Big", self.lib)
        pl.extend(SONGS)
        pl.write()

        pl = Playlist.new(PLAYLISTS, "Small", self.lib)
        pl.extend([self.ANOTHER_SONG])
        pl.write()

        PlaylistsBrowser.init(self.lib)

        self.bar = PlaylistsBrowser(self.lib)
        self.bar.connect('songs-selected', self._expected)
        self.bar._select_playlist(self.bar.playlists()[0])
        self.expected = None
开发者ID:vrasidas,项目名称:quodlibet,代码行数:29,代码来源:test_browsers_playlists.py

示例8: test_manydeep

 def test_manydeep(self):
     self.failUnless(not os.path.isdir("nonext"))
     mkdir("nonext/test/test2/test3")
     try:
         self.failUnless(os.path.isdir("nonext/test/test2/test3"))
     finally:
         os.rmdir("nonext/test/test2/test3")
         os.rmdir("nonext/test/test2")
         os.rmdir("nonext/test")
         os.rmdir("nonext")
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:10,代码来源:test_util.py

示例9: get_cache_dir

def get_cache_dir():
    """The directory to store things into which can be deleted at any time"""

    if os.name == "nt" and build.BUILD_TYPE == u"windows-portable":
        # avoid writing things to the host system for the portable build
        path = os.path.join(get_user_dir(), "cache")
    else:
        path = os.path.join(xdg_get_cache_home(), "quodlibet")

    mkdir(path, 0o700)
    return path
开发者ID:zsau,项目名称:quodlibet,代码行数:11,代码来源:_main.py

示例10: test_lyric_filename_search_builtin_default

 def test_lyric_filename_search_builtin_default(self):
     """test built-in default"""
     with self.lyric_filename_test_setup(no_config=True) as ts:
         fp = os.path.join(ts.root, ts["artist"], ts["title"] + ".lyric")
         p = os.path.dirname(fp)
         mkdir(p)
         with io.open(fp, "w", encoding='utf-8') as f:
             f.write(u"")
         search = unquote(ts.lyric_filename)
         os.remove(fp)
         os.rmdir(p)
         self.assertEqual(search, fp)
开发者ID:LudoBike,项目名称:quodlibet,代码行数:12,代码来源:test_formats__audio.py

示例11: test_lyrics_from_file

 def test_lyrics_from_file(self):
     with temp_filename() as filename:
         af = AudioFile(artist='Motörhead', title='this: again')
         af.sanitize(filename)
         lyrics = "blah!\nblasé 😬\n"
         lyrics_dir = os.path.dirname(af.lyric_filename)
         mkdir(lyrics_dir)
         with io.open(af.lyric_filename, "w", encoding='utf-8') as lf:
             lf.write(text_type(lyrics))
         self.failUnlessEqual(af("~lyrics").splitlines(),
                              lyrics.splitlines())
         os.remove(af.lyric_filename)
         os.rmdir(lyrics_dir)
开发者ID:Muges,项目名称:quodlibet,代码行数:13,代码来源:test_formats__audio.py

示例12: dump_to_disk

    def dump_to_disk(self, type_, value, traceback):
        """Writes the dump files to DUMDIR"""

        mkdir(self.DUMPDIR)

        header = format_dump_header(type_, value, traceback).encode("utf-8")
        log = format_dump_log().encode("utf-8")

        print(self.dump_path)
        with open(self.dump_path, "wb") as dump:
            with open(self.minidump_path, "wb") as minidump:
                minidump.write(header)
                dump.write(header)
            dump.write(log)
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:14,代码来源:debugwindow.py

示例13: from_except

    def from_except(Kind, *args):
        mkdir(Kind.DUMPDIR)

        dump = os.path.join(
            Kind.DUMPDIR, time.strftime("Dump_%Y%m%d_%H%M%S.txt"))
        minidump = os.path.join(
            Kind.DUMPDIR, time.strftime("MiniDump_%Y%m%d_%H%M%S.txt"))

        full_args = list(args) + [dump, minidump]
        Kind.__dump(*full_args)
        # Don't get in a recursive exception handler loop.
        if not Kind.running:
            Kind.running = True
            Kind.instance = Kind(*full_args)
        return Kind.instance
开发者ID:brunob,项目名称:quodlibet,代码行数:15,代码来源:debugwindow.py

示例14: rename

    def rename(self, newname):
        """Rename a file. Errors are not handled. This shouldn't be used
        directly; use library.rename instead."""

        if os.path.isabs(newname):
            mkdir(os.path.dirname(newname))
        else:
            newname = os.path.join(self('~dirname'), newname)

        if not os.path.exists(newname):
            shutil.move(self['~filename'], newname)
        elif normalize_path(newname, canonicalise=True) != self['~filename']:
            raise ValueError

        self.sanitize(newname)
开发者ID:elfalem,项目名称:quodlibet,代码行数:15,代码来源:_audio.py

示例15: _open

    def _open(self, *args):
        from quodlibet import qltk

        self._id = None
        try:
            if not os.path.exists(self._path):
                mkdir(os.path.dirname(self._path))
                os.mkfifo(self._path, 0600)
            fifo = os.open(self._path, os.O_NONBLOCK)
            f = os.fdopen(fifo, "r", 4096)
            self._id = qltk.io_add_watch(
                f, GLib.PRIORITY_DEFAULT,
                GLib.IO_IN | GLib.IO_ERR | GLib.IO_HUP,
                self._process, *args)
        except (EnvironmentError, AttributeError):
            pass
开发者ID:kriskielce88,项目名称:xn--ls8h,代码行数:16,代码来源:fifo.py


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