当前位置: 首页>>代码示例>>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;未经允许,请勿转载。