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


Python path.isabs方法代码示例

本文整理汇总了Python中os.path.isabs方法的典型用法代码示例。如果您正苦于以下问题:Python path.isabs方法的具体用法?Python path.isabs怎么用?Python path.isabs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在os.path的用法示例。


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

示例1: get

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import isabs [as 别名]
def get(self, model_directory):
        """ Ensures required model is available at given location.

        :param model_directory: Expected model_directory to be available.
        :raise IOError: If model can not be retrieved.
        """
        # Expend model directory if needed.
        if not isabs(model_directory):
            model_directory = join(self.DEFAULT_MODEL_PATH, model_directory)
        # Download it if not exists.
        model_probe = join(model_directory, self.MODEL_PROBE_PATH)
        if not exists(model_probe):
            if not exists(model_directory):
                makedirs(model_directory)
                self.download(
                    model_directory.split(sep)[-1],
                    model_directory)
                self.writeProbe(model_directory)
        return model_directory 
开发者ID:deezer,项目名称:spleeter,代码行数:21,代码来源:__init__.py

示例2: _move

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import isabs [as 别名]
def _move(self, path):
        if path == self.path:
            return

        files = self.get_marked() or self.get_selected()

        if not isabs(path):
            path = join(self.path, path)
        if not isdir(path):
            sublime.error_message('Not a valid directory: {}'.format(path))
            return

        # Move all items into the target directory.  If the target directory was also selected,
        # ignore it.
        files = self.get_marked() or self.get_selected()
        path = normpath(path)
        for filename in files:
            fqn = normpath(join(self.path, filename))
            if fqn != path:
                shutil.move(fqn, path)
        self.view.run_command('dired_refresh') 
开发者ID:kublaios,项目名称:dired,代码行数:23,代码来源:dired.py

示例3: send2trash

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import isabs [as 别名]
def send2trash(path):
    if not isinstance(path, text_type):
        path = text_type(path, 'mbcs')
    if not op.isabs(path):
        path = op.abspath(path)
    fileop = SHFILEOPSTRUCTW()
    fileop.hwnd = 0
    fileop.wFunc = FO_DELETE
    fileop.pFrom = LPCWSTR(path + '\0')
    fileop.pTo = None
    fileop.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT
    fileop.fAnyOperationsAborted = 0
    fileop.hNameMappings = 0
    fileop.lpszProgressTitle = None
    result = SHFileOperationW(byref(fileop))
    if result:
        msg = "Couldn't perform operation. Error code: %d" % result
        raise OSError(msg) 
开发者ID:liorbenhorin,项目名称:pipeline,代码行数:20,代码来源:plat_win.py

示例4: remove_local_modules_from_sys

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import isabs [as 别名]
def remove_local_modules_from_sys(testdir):
    """remove all modules from cache that come from `testdir`

    This is used to avoid strange side-effects when using the
    testall() mode of pytest.
    For instance, if we run pytest on this tree::
    
      A/test/test_utils.py
      B/test/test_utils.py

    we **have** to clean sys.modules to make sure the correct test_utils
    module is ran in B
    """
    for modname, mod in list(sys.modules.items()):
        if mod is None:
            continue
        if not hasattr(mod, '__file__'):
            # this is the case of some built-in modules like sys, imp, marshal
            continue
        modfile = mod.__file__
        # if modfile is not an asbolute path, it was probably loaded locally
        # during the tests
        if not osp.isabs(modfile) or modfile.startswith(testdir):
            del sys.modules[modname] 
开发者ID:jlachowski,项目名称:clonedigger,代码行数:26,代码来源:pytest.py

示例5: __init__

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import isabs [as 别名]
def __init__(self, root):
    """
      Initializes the sandbox.

      :param root: Root path of the sandbox.

      The sandbox makes sure that the folder paths it exposes as properties are created.
    """
    if not isabs(root):
      raise ValueError("Only an absolute path is allowed for 'root")

    self._root = root

    safe_mkdir(self.bin)
    safe_mkdir(self.lib)
    safe_mkdir(self.var)
    safe_mkdir(self.mysql_var)
    safe_mkdir(self.mysql_data_dir)
    safe_mkdir(self.mysql_tmp_dir)
    safe_mkdir(self.mysql_log_dir) 
开发者ID:apache,项目名称:incubator-retired-cotton,代码行数:22,代码来源:sandbox.py

示例6: __sanitize

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import isabs [as 别名]
def __sanitize(self, pathname):
        """
        Makes sure the given pathname lies within the plugin folder.
        Also makes it an absolute pathname.

        .. warning: Internally used by GoLismero, do not call!
        """

        # Absolute pathnames are not allowed.
        if path.isabs(pathname):
            msg = "Absolute pathnames are not allowed: %r"
            raise ValueError(msg % pathname)

        # Turn the pathname into a local pathname within the plugin folder.
        pathname = path.join(self.plugin_path, pathname)
        pathname = path.abspath(pathname)
        if not pathname.startswith(self.plugin_path):
            msg = "Pathname may not be outside the plugin folder: %r"
            raise ValueError(msg % self.plugin_path)

        # Return the sanitized pathname.
        return pathname


    #-------------------------------------------------------------------------- 
开发者ID:blackye,项目名称:luscan-devel,代码行数:27,代码来源:localfile.py

示例7: _get_credentials_path

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import isabs [as 别名]
def _get_credentials_path(self):
        recommended_path = path.expanduser('~') + '/.aws/credentials'
        creds_path = ""
        if not self.non_interactive:
            while not path.isabs(creds_path):
                creds_path = Prompt(
                    message="Enter absolute path to AWS credentials file [" + Color.green(recommended_path) + "]: ",
                    default=recommended_path).run()
        else:
            if self.creds_path:
                if path.isabs(self.creds_path):
                    creds_path = self.creds_path
            else:
                creds_path = recommended_path
        make_dirs(path.dirname(creds_path))
        return creds_path 
开发者ID:awslabs,项目名称:collectd-cloudwatch,代码行数:18,代码来源:setup.py

示例8: canonical_path

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import isabs [as 别名]
def canonical_path(input_path, folder=''):
        """Return a canonical path of the file.

        Args:
            input_path (str): path to convert.
            folder (str, optional): parent folder.

        Returns:
            str: canonical path
        """
        if not input_path:
            return None
        input_path = path.expanduser(input_path)
        if not path.isabs(input_path):
            input_path = path.join(folder, input_path)
        normpath = path.normpath(input_path)
        if path.exists(normpath):
            return path.realpath(normpath)
        return normpath 
开发者ID:niosus,项目名称:EasyClangComplete,代码行数:21,代码来源:file.py

示例9: __get_cmake_deps

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import isabs [as 别名]
def __get_cmake_deps(deps_file):
        """Parse dependencies from Makefile.cmake.

        Args:
            deps_file (str): Full path to Makefile.cmake file.

        Returns:
            str[]: List of full paths to dependency files.
        """
        folder = path.dirname(path.dirname(deps_file))
        deps = []
        with open(deps_file, 'r') as f:
            content = f.read()
            found = CMakeFile._DEP_REGEX.findall(content)
            for dep in found:
                if not path.isabs(dep):
                    dep = path.join(folder, dep)
                deps.append(dep)
        return deps 
开发者ID:niosus,项目名称:EasyClangComplete,代码行数:21,代码来源:cmake_file.py

示例10: load_catalog

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import isabs [as 别名]
def load_catalog(self, catalog_path, ignore_missing=True):
        catalog = path.abspath(catalog_path)
        catalog_dir = path.dirname(catalog)
        with open(catalog, 'r') as catalog_file:
            catalog_entries = json.load(catalog_file)
        for entry in AlignmentStatistics.progress(catalog_entries, desc='Reading catalog'):
            aligned_path = entry['aligned']
            if not path.isabs(aligned_path):
                aligned_path = path.join(catalog_dir, aligned_path)
            if path.isfile(aligned_path):
                self.load_aligned(aligned_path)
            else:
                if ignore_missing:
                    continue
                else:
                    fail('Problem loading catalog "{}": Missing referenced alignment file "{}"'
                         .format(catalog_path, aligned_path)) 
开发者ID:mozilla,项目名称:DSAlign,代码行数:19,代码来源:stats.py

示例11: test

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import isabs [as 别名]
def test():
            filename = p.relpath(
                p.join(TEST_PROJECT, "another_library", "foo.vhd"),
                str(it.project.root_dir),
            )

            it.assertFalse(p.isabs(filename))

            diagnostics = it.project.getMessagesByPath(Path(filename))

            it.assertIn(
                ObjectIsNeverUsed(
                    filename=Path(p.join(TEST_PROJECT, "another_library", "foo.vhd")),
                    line_number=28,
                    column_number=11,
                    object_type="signal",
                    object_name="neat_signal",
                ),
                diagnostics,
            ) 
开发者ID:suoto,项目名称:hdl_checker,代码行数:22,代码来源:test_base_server.py

示例12: timid_relpath

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import isabs [as 别名]
def timid_relpath(arg):
    """convert an argument to a relative path, carefully"""
    # TODO-TEST: unit tests
    from os.path import isabs, relpath, sep
    if isabs(arg):
        result = relpath(arg)
        if result.count(sep) + 1 < arg.count(sep):
            return result

    return arg 
开发者ID:edmundmok,项目名称:mealpy,代码行数:12,代码来源:venv_update.py

示例13: __init__

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import isabs [as 别名]
def __init__(self, app):

        self._app = app
        self._root_dir = config.get("root_dir")
        if not self._root_dir:
            log.error("FileClient init: root_dir config not set")
            raise HTTPInternalServerError()
        if not pp.isdir(self._root_dir):
            log.error("FileClient init: root folder does not exist")
            raise HTTPInternalServerError()
        if not pp.isabs(self._root_dir):
            log.error("FileClient init: root dir most have absolute path")
            raise HTTPInternalServerError() 
开发者ID:HDFGroup,项目名称:hsds,代码行数:15,代码来源:fileClient.py

示例14: _validateBucket

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import isabs [as 别名]
def _validateBucket(self, bucket):
        if not bucket or pp.isabs(bucket) or pp.dirname(bucket):
            msg = "invalid bucket name"
            log.warn(msg)
            raise HTTPBadRequest(reason=msg) 
开发者ID:HDFGroup,项目名称:hsds,代码行数:7,代码来源:fileClient.py

示例15: _validateKey

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import isabs [as 别名]
def _validateKey(self, key):
        if not key or pp.isabs(key):
            msg = "invalid key name"
            log.warn(msg)
            raise HTTPBadRequest(reason=msg) 
开发者ID:HDFGroup,项目名称:hsds,代码行数:7,代码来源:fileClient.py


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