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


Python os.curdir方法代码示例

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


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

示例1: _candidate_tempdir_list

# 需要导入模块: import os [as 别名]
# 或者: from os import curdir [as 别名]
def _candidate_tempdir_list():
    """Generate a list of candidate temporary directories which
    _get_default_tempdir will try."""

    dirlist = []

    # First, try the environment.
    for envname in 'TMPDIR', 'TEMP', 'TMP':
        dirname = _os.getenv(envname)
        if dirname: dirlist.append(dirname)

    # Failing that, try OS-specific locations.
    if _os.name == 'nt':
        dirlist.extend([ r'c:\temp', r'c:\tmp', r'\temp', r'\tmp' ])
    else:
        dirlist.extend([ '/tmp', '/var/tmp', '/usr/tmp' ])

    # As a last resort, the current directory.
    try:
        dirlist.append(_os.getcwd())
    except (AttributeError, OSError):
        dirlist.append(_os.curdir)

    return dirlist 
开发者ID:war-and-code,项目名称:jawfish,代码行数:26,代码来源:tempfile.py

示例2: translate_path

# 需要导入模块: import os [as 别名]
# 或者: from os import curdir [as 别名]
def translate_path(self, path):
        """Translate a /-separated PATH to the local filename syntax.

        Components that mean special things to the local file system
        (e.g. drive or directory names) are ignored.  (XXX They should
        probably be diagnosed.)

        """
        # abandon query parameters
        path = path.split('?',1)[0]
        path = path.split('#',1)[0]
        path = posixpath.normpath(urllib_parse.unquote(path))
        words = path.split('/')
        words = filter(None, words)
        path = os.getcwd()
        for word in words:
            drive, word = os.path.splitdrive(word)
            head, word = os.path.split(word)
            if word in (os.curdir, os.pardir): continue
            path = os.path.join(path, word)
        return path 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:23,代码来源:server.py

示例3: bestrelpath

# 需要导入模块: import os [as 别名]
# 或者: from os import curdir [as 别名]
def bestrelpath(self, dest):
        """ return a string which is a relative path from self
            (assumed to be a directory) to dest such that
            self.join(bestrelpath) == dest and if not such
            path can be determined return dest.
        """
        try:
            if self == dest:
                return os.curdir
            base = self.common(dest)
            if not base:  # can be the case on windows
                return str(dest)
            self2base = self.relto(base)
            reldest = dest.relto(base)
            if self2base:
                n = self2base.count(self.sep) + 1
            else:
                n = 0
            l = [os.pardir] * n
            if reldest:
                l.append(reldest)
            target = dest.sep.join(l)
            return target
        except AttributeError:
            return str(dest) 
开发者ID:pytest-dev,项目名称:py,代码行数:27,代码来源:common.py

示例4: build

# 需要导入模块: import os [as 别名]
# 或者: from os import curdir [as 别名]
def build(self):
        use_windows_commands = os.name == 'nt'
        command = "build" if use_windows_commands else "./build.sh"
        if self.options.toolset != 'auto':
            command += " "+str(self.options.toolset)
        build_dir = os.path.join(self.source_folder, "source")
        engine_dir = os.path.join(build_dir, "src", "engine")
        os.chdir(engine_dir)
        with tools.environment_append({"VSCMD_START_DIR": os.curdir}):
            if self.options.use_cxx_env:
                # Allow use of CXX env vars.
                self.run(command)
            else:
                # To avoid using the CXX env vars we clear them out for the build.
                with tools.environment_append({"CXX": "", "CXXFLAGS": ""}):
                    self.run(command)
        os.chdir(build_dir)
        command = os.path.join(
            engine_dir, "b2.exe" if use_windows_commands else "b2")
        full_command = \
            "{0} --ignore-site-config --prefix=../output --abbreviate-paths install".format(
                command)
        self.run(full_command) 
开发者ID:conan-io,项目名称:conan-center-index,代码行数:25,代码来源:conanfile.py

示例5: download_setuptools

# 需要导入模块: import os [as 别名]
# 或者: from os import curdir [as 别名]
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
                        to_dir=os.curdir, delay=15, downloader_factory=get_best_downloader):
    """
    Download setuptools from a specified location and return its filename

    `version` should be a valid setuptools version number that is available
    as an egg for download under the `download_base` URL (which should end
    with a '/'). `to_dir` is the directory where the egg will be downloaded.
    `delay` is the number of seconds to pause before an actual download
    attempt.

    ``downloader_factory`` should be a function taking no arguments and
    returning a function for downloading a URL to a target.
    """
    # making sure we use the absolute path
    to_dir = os.path.abspath(to_dir)
    zip_name = "setuptools-%s.zip" % version
    url = download_base + zip_name
    saveto = os.path.join(to_dir, zip_name)
    if not os.path.exists(saveto):  # Avoid repeated downloads
        log.warn("Downloading %s", url)
        downloader = downloader_factory()
        downloader(url, saveto)
    return os.path.realpath(saveto) 
开发者ID:fangpenlin,项目名称:bugbuzz-python,代码行数:26,代码来源:ez_setup.py

示例6: normalize_path

# 需要导入模块: import os [as 别名]
# 或者: from os import curdir [as 别名]
def normalize_path(path, parent=os.curdir):
    # type: (str, str) -> str
    """Normalize a single-path.

    :returns:
        The normalized path.
    :rtype:
        str
    """
    # NOTE(sigmavirus24): Using os.path.sep and os.path.altsep allow for
    # Windows compatibility with both Windows-style paths (c:\\foo\bar) and
    # Unix style paths (/foo/bar).
    separator = os.path.sep
    # NOTE(sigmavirus24): os.path.altsep may be None
    alternate_separator = os.path.altsep or ''
    if separator in path or (alternate_separator and
                             alternate_separator in path):
        path = os.path.abspath(os.path.join(parent, path))
    return path.rstrip(separator + alternate_separator) 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:21,代码来源:utils.py

示例7: normalize_paths

# 需要导入模块: import os [as 别名]
# 或者: from os import curdir [as 别名]
def normalize_paths(value, parent=os.curdir):
    """Parse a comma-separated list of paths.

    Return a list of absolute paths.
    """
    if not value:
        return []
    if isinstance(value, list):
        return value
    paths = []
    for path in value.split(','):
        path = path.strip()
        if '/' in path:
            path = os.path.abspath(os.path.join(parent, path))
        paths.append(path.rstrip('/'))
    return paths 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:18,代码来源:pycodestyle.py

示例8: convert_path

# 需要导入模块: import os [as 别名]
# 或者: from os import curdir [as 别名]
def convert_path(pathname):
    """Return 'pathname' as a name that will work on the native filesystem.

    The path is split on '/' and put back together again using the current
    directory separator.  Needed because filenames in the setup script are
    always supplied in Unix style, and have to be converted to the local
    convention before we can actually use them in the filesystem.  Raises
    ValueError on non-Unix-ish systems if 'pathname' either starts or
    ends with a slash.
    """
    if os.sep == '/':
        return pathname
    if not pathname:
        return pathname
    if pathname[0] == '/':
        raise ValueError("path '%s' cannot be absolute" % pathname)
    if pathname[-1] == '/':
        raise ValueError("path '%s' cannot end with '/'" % pathname)

    paths = pathname.split('/')
    while os.curdir in paths:
        paths.remove(os.curdir)
    if not paths:
        return os.curdir
    return os.path.join(*paths) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:27,代码来源:util.py

示例9: _update_namespaces

# 需要导入模块: import os [as 别名]
# 或者: from os import curdir [as 别名]
def _update_namespaces(self) -> None:
        """Get the available namespaces.
        """

        # user defined search paths
        dir_list = set()
        self.namespaces = dict()
        for k, v in settings['SEARCH_PATHS'].items():
            if os.path.isdir(v):
                meta_path = os.path.join(v, settings['NAMESPACE_CONFIG_FILENAME'])
                meta = U.load_yaml(meta_path)[0] if os.path.exists(meta_path) else dict()
                meta['module_path'] = os.path.abspath(os.path.join(v, meta.get('module_path', './')))
                if os.path.isdir(meta['module_path']):
                    self.namespaces[k] = meta
                    dir_list.add(meta['module_path'])
                else:
                    U.alert_msg('Namespace "%s" has an invalid module path "%s".' % (k, meta['module_path']))

        # current path
        current_path = os.path.abspath(os.curdir)
        if not current_path in dir_list:
            self.namespaces['main'] = dict(module_path=current_path) 
开发者ID:ZhouYanzhao,项目名称:Nest,代码行数:24,代码来源:modules.py

示例10: download_setuptools

# 需要导入模块: import os [as 别名]
# 或者: from os import curdir [as 别名]
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
        to_dir=os.curdir, delay=15, downloader_factory=get_best_downloader):
    """
    Download setuptools from a specified location and return its filename

    `version` should be a valid setuptools version number that is available
    as an egg for download under the `download_base` URL (which should end
    with a '/'). `to_dir` is the directory where the egg will be downloaded.
    `delay` is the number of seconds to pause before an actual download
    attempt.

    ``downloader_factory`` should be a function taking no arguments and
    returning a function for downloading a URL to a target.
    """
    # making sure we use the absolute path
    to_dir = os.path.abspath(to_dir)
    zip_name = "setuptools-%s.zip" % version
    url = download_base + zip_name
    saveto = os.path.join(to_dir, zip_name)
    if not os.path.exists(saveto):  # Avoid repeated downloads
        log.warn("Downloading %s", url)
        downloader = downloader_factory()
        downloader(url, saveto)
    return os.path.realpath(saveto) 
开发者ID:jeremybmerrill,项目名称:flyover,代码行数:26,代码来源:ez_setup.py

示例11: copy_extensions_to_source

# 需要导入模块: import os [as 别名]
# 或者: from os import curdir [as 别名]
def copy_extensions_to_source(self):
        build_py = self.get_finalized_command('build_py')
        for ext in self.extensions:
            fullname = self.get_ext_fullname(ext.name)
            filename = self.get_ext_filename(fullname)
            modpath = fullname.split('.')
            package = '.'.join(modpath[:-1])
            package_dir = build_py.get_package_dir(package)
            dest_filename = os.path.join(package_dir,
                                         os.path.basename(filename))
            src_filename = os.path.join(self.build_lib, filename)

            # Always copy, even if source is older than destination, to ensure
            # that the right extensions for the current Python/platform are
            # used.
            copy_file(
                src_filename, dest_filename, verbose=self.verbose,
                dry_run=self.dry_run
            )
            if ext._needs_stub:
                self.write_stub(package_dir or os.curdir, ext, True) 
开发者ID:jpush,项目名称:jbox,代码行数:23,代码来源:build_ext.py

示例12: build_assets

# 需要导入模块: import os [as 别名]
# 或者: from os import curdir [as 别名]
def build_assets(args):
    """
    Build the longclaw assets
    """
    # Get the path to the JS directory
    asset_path = path.join(path.dirname(longclaw.__file__), 'client')
    try:
        # Move into client dir
        curdir = os.path.abspath(os.curdir)
        os.chdir(asset_path)
        print('Compiling assets....')
        subprocess.check_call(['npm', 'install'])
        subprocess.check_call(['npm', 'run', 'build'])
        os.chdir(curdir)
        print('Complete!')
    except (OSError, subprocess.CalledProcessError) as err:
        print('Error compiling assets:  {}'.format(err))
        raise SystemExit(1) 
开发者ID:JamesRamm,项目名称:longclaw,代码行数:20,代码来源:longclaw.py

示例13: getLogger

# 需要导入模块: import os [as 别名]
# 或者: from os import curdir [as 别名]
def getLogger(self):
        """
        Get logger configuration and create instance of a logger
        """
        # Known paths where loggingConfig.ini can exist
        relpath1 = os.path.join('etc', 'faraday')
        relpath2 = os.path.join('..', 'etc', 'faraday')
        setuppath = os.path.join(sys.prefix, 'etc', 'faraday')
        userpath = os.path.join(os.path.expanduser('~'), '.faraday')
        self.path = ''

        # Check all directories until first instance of loggingConfig.ini
        for location in os.curdir, relpath1, relpath2, setuppath, userpath:
            try:
                logging.config.fileConfig(os.path.join(location, "loggingConfig.ini"))
                self.path = location
                break
            except ConfigParser.NoSectionError:
                pass

        self._logger = logging.getLogger(self._name)
        return self._logger 
开发者ID:FaradayRF,项目名称:Faraday-Software,代码行数:24,代码来源:helper.py

示例14: cmdline_for_run

# 需要导入模块: import os [as 别名]
# 或者: from os import curdir [as 别名]
def cmdline_for_run(tool, executable, options, sourcefiles, propertyfile, rlimits):
    working_directory = tool.working_directory(executable)

    def relpath(path):
        return path if os.path.isabs(path) else os.path.relpath(path, working_directory)

    rel_executable = relpath(executable)
    if os.path.sep not in rel_executable:
        rel_executable = os.path.join(os.curdir, rel_executable)
    args = tool.cmdline(
        rel_executable,
        list(options),
        list(map(relpath, sourcefiles)),
        relpath(propertyfile) if propertyfile else None,
        rlimits.copy(),
    )
    assert all(args), "Tool cmdline contains empty or None argument: " + str(args)
    args = [os.path.expandvars(arg) for arg in args]
    args = [os.path.expanduser(arg) for arg in args]
    return args 
开发者ID:sosy-lab,项目名称:benchexec,代码行数:22,代码来源:model.py

示例15: save_params

# 需要导入模块: import os [as 别名]
# 或者: from os import curdir [as 别名]
def save_params(dir_path=os.curdir, epoch=None, name="", params=None, aux_states=None,
                ctx=mx.cpu()):
    prefix = os.path.join(dir_path, name)
    _, param_saving_path, _ = get_saving_path(prefix, epoch)
    if not os.path.isdir(dir_path) and not (dir_path == ""):
        os.makedirs(dir_path)
    save_dict = {('arg:%s' % k): v.copyto(ctx) for k, v in params.items()}
    save_dict.update({('aux:%s' % k): v.copyto(ctx) for k, v in aux_states.items()})
    nd.save(param_saving_path, save_dict)
    return param_saving_path 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:12,代码来源:utils.py


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