當前位置: 首頁>>代碼示例>>Python>>正文


Python cbook.mkdirs方法代碼示例

本文整理匯總了Python中matplotlib.cbook.mkdirs方法的典型用法代碼示例。如果您正苦於以下問題:Python cbook.mkdirs方法的具體用法?Python cbook.mkdirs怎麽用?Python cbook.mkdirs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib.cbook的用法示例。


在下文中一共展示了cbook.mkdirs方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _image_directories

# 需要導入模塊: from matplotlib import cbook [as 別名]
# 或者: from matplotlib.cbook import mkdirs [as 別名]
def _image_directories(func):
    """
    Compute the baseline and result image directories for testing *func*.
    Create the result directory if it doesn't exist.
    """
    module_name = func.__module__
    if module_name == '__main__':
        # FIXME: this won't work for nested packages in matplotlib.tests
        warnings.warn('test module run as script. guessing baseline image locations')
        script_name = sys.argv[0]
        basedir = os.path.abspath(os.path.dirname(script_name))
        subdir = os.path.splitext(os.path.split(script_name)[1])[0]
    else:
        mods = module_name.split('.')
        mods.pop(0) # <- will be the name of the package being tested (in
                    # most cases "matplotlib")
        assert mods.pop(0) == 'tests'
        subdir = os.path.join(*mods)

        import imp
        def find_dotted_module(module_name, path=None):
            """A version of imp which can handle dots in the module name"""
            res = None
            for sub_mod in module_name.split('.'):
                res = file, path, _ = imp.find_module(sub_mod, path)
                path = [path]
                if file is not None:
                    file.close()
            return res

        mod_file = find_dotted_module(func.__module__)[1]
        basedir = os.path.dirname(mod_file)

    baseline_dir = os.path.join(basedir, 'baseline_images', subdir)
    result_dir = os.path.abspath(os.path.join('result_images', subdir))

    if not os.path.exists(result_dir):
        cbook.mkdirs(result_dir)

    return baseline_dir, result_dir 
開發者ID:Solid-Mechanics,項目名稱:matplotlib-4-abaqus,代碼行數:42,代碼來源:decorators.py

示例2: get_cache_dir

# 需要導入模塊: from matplotlib import cbook [as 別名]
# 或者: from matplotlib.cbook import mkdirs [as 別名]
def get_cache_dir():
   cachedir = _get_cachedir()
   if cachedir is None:
      raise RuntimeError('Could not find a suitable configuration directory')
   cache_dir = os.path.join(cachedir, 'test_cache')
   if not os.path.exists(cache_dir):
      try:
         cbook.mkdirs(cache_dir)
      except IOError:
         return None
   if not os.access(cache_dir, os.W_OK):
      return None
   return cache_dir 
開發者ID:Solid-Mechanics,項目名稱:matplotlib-4-abaqus,代碼行數:15,代碼來源:compare.py

示例3: get_cache_dir

# 需要導入模塊: from matplotlib import cbook [as 別名]
# 或者: from matplotlib.cbook import mkdirs [as 別名]
def get_cache_dir():
    cachedir = _get_cachedir()
    if cachedir is None:
        raise RuntimeError('Could not find a suitable configuration directory')
    cache_dir = os.path.join(cachedir, 'test_cache')
    if not os.path.exists(cache_dir):
        try:
            cbook.mkdirs(cache_dir)
        except IOError:
            return None
    if not os.access(cache_dir, os.W_OK):
        return None
    return cache_dir 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:15,代碼來源:compare.py

示例4: _image_directories

# 需要導入模塊: from matplotlib import cbook [as 別名]
# 或者: from matplotlib.cbook import mkdirs [as 別名]
def _image_directories(func):
    """
    Compute the baseline and result image directories for testing *func*.
    Create the result directory if it doesn't exist.
    """
    module_name = func.__module__
#     mods = module_name.split('.')
#     mods.pop(0) # <- will be the name of the package being tested (in
                # most cases "matplotlib")
#     assert mods.pop(0) == 'tests'
#     subdir = os.path.join(*mods)
    subdir = module_name

    import imp
    def find_dotted_module(module_name, path=None):
        """A version of imp which can handle dots in the module name"""
        res = None
        for sub_mod in module_name.split('.'):
            try:
                res = file, path, _ = imp.find_module(sub_mod, path)
                path = [path]
                if file is not None:
                    file.close()
            except ImportError:
                # assume namespace package
                path = sys.modules[sub_mod].__path__
                res = None, path, None
        return res

    mod_file = find_dotted_module(func.__module__)[1]
    basedir = os.path.dirname(mod_file)

    baseline_dir = os.path.join(basedir, 'baseline_images', subdir)
    result_dir = os.path.abspath(os.path.join('result_images', subdir))

    if not os.path.exists(result_dir):
        cbook.mkdirs(result_dir)

    return baseline_dir, result_dir 
開發者ID:urinieto,項目名稱:msaf,代碼行數:41,代碼來源:mpl_ic.py

示例5: _image_directories

# 需要導入模塊: from matplotlib import cbook [as 別名]
# 或者: from matplotlib.cbook import mkdirs [as 別名]
def _image_directories(func):
    """
    Compute the baseline and result image directories for testing *func*.
    Create the result directory if it doesn't exist.
    """
    module_name = func.__module__
    if module_name == '__main__':
        # FIXME: this won't work for nested packages in matplotlib.tests
        warnings.warn('test module run as script. guessing baseline image locations')
        script_name = sys.argv[0]
        basedir = os.path.abspath(os.path.dirname(script_name))
        subdir = os.path.splitext(os.path.split(script_name)[1])[0]
    else:
        mods = module_name.split('.')
        mods.pop(0) # <- will be the name of the package being tested (in
                    # most cases "matplotlib")
        assert mods.pop(0) == 'tests'
        subdir = os.path.join(*mods)

        import imp
        def find_dotted_module(module_name, path=None):
            """A version of imp which can handle dots in the module name"""
            res = None
            for sub_mod in module_name.split('.'):
                try:
                    res = file, path, _ = imp.find_module(sub_mod, path)
                    path = [path]
                    if file is not None:
                        file.close()
                except ImportError:
                    # assume namespace package
                    path = sys.modules[sub_mod].__path__
                    res = None, path, None
            return res

        mod_file = find_dotted_module(func.__module__)[1]
        basedir = os.path.dirname(mod_file)

    baseline_dir = os.path.join(basedir, 'baseline_images', subdir)
    result_dir = os.path.abspath(os.path.join('result_images', subdir))

    if not os.path.exists(result_dir):
        cbook.mkdirs(result_dir)

    return baseline_dir, result_dir 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:47,代碼來源:decorators.py

示例6: _image_directories

# 需要導入模塊: from matplotlib import cbook [as 別名]
# 或者: from matplotlib.cbook import mkdirs [as 別名]
def _image_directories(func):
    """
    Compute the baseline and result image directories for testing *func*.
    Create the result directory if it doesn't exist.
    """
    module_name = func.__module__
    if module_name == '__main__':
        # FIXME: this won't work for nested packages in matplotlib.tests
        warnings.warn(
            'Test module run as script. Guessing baseline image locations.')
        script_name = sys.argv[0]
        basedir = os.path.abspath(os.path.dirname(script_name))
        subdir = os.path.splitext(os.path.split(script_name)[1])[0]
    else:
        mods = module_name.split('.')
        if len(mods) >= 3:
            mods.pop(0)
            # mods[0] will be the name of the package being tested (in
            # most cases "matplotlib") However if this is a
            # namespace package pip installed and run via the nose
            # multiprocess plugin or as a specific test this may be
            # missing. See https://github.com/matplotlib/matplotlib/issues/3314
        if mods.pop(0) != 'tests':
            warnings.warn(
                "Module {!r} does not live in a parent module named 'tests'. "
                "This is probably ok, but we may not be able to guess the "
                "correct subdirectory containing the baseline images. If "
                "things go wrong please make sure that there is a parent "
                "directory named 'tests' and that it contains a __init__.py "
                "file (can be empty).".format(module_name))
        subdir = os.path.join(*mods)

        import imp
        def find_dotted_module(module_name, path=None):
            """A version of imp which can handle dots in the module name.
               As for imp.find_module(), the return value is a 3-element
               tuple (file, pathname, description)."""
            res = None
            for sub_mod in module_name.split('.'):
                try:
                    res = file, path, _ = imp.find_module(sub_mod, path)
                    path = [path]
                    if file is not None:
                        file.close()
                except ImportError:
                    # assume namespace package
                    path = list(sys.modules[sub_mod].__path__)
                    res = None, path, None
            return res

        mod_file = find_dotted_module(func.__module__)[1]
        basedir = os.path.dirname(mod_file)

    baseline_dir = os.path.join(basedir, 'baseline_images', subdir)
    result_dir = os.path.abspath(os.path.join('result_images', subdir))

    if not os.path.exists(result_dir):
        cbook.mkdirs(result_dir)

    return baseline_dir, result_dir 
開發者ID:alvarobartt,項目名稱:twitter-stock-recommendation,代碼行數:62,代碼來源:decorators.py


注:本文中的matplotlib.cbook.mkdirs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。