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


Python os.getcwdu方法代码示例

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


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

示例1: _env_info

# 需要导入模块: import os [as 别名]
# 或者: from os import getcwdu [as 别名]
def _env_info():
    """
    :return:
        A two-element tuple of unicode strings. The first is the name of the
        environment, the second the root of the repo. The environment name
        will be one of: "ci-travis", "ci-circle", "ci-appveyor",
        "ci-github-actions", "local"
    """

    if os.getenv('CI') == 'true' and os.getenv('TRAVIS') == 'true':
        return ('ci-travis', os.getenv('TRAVIS_BUILD_DIR'))

    if os.getenv('CI') == 'True' and os.getenv('APPVEYOR') == 'True':
        return ('ci-appveyor', os.getenv('APPVEYOR_BUILD_FOLDER'))

    if os.getenv('CI') == 'true' and os.getenv('CIRCLECI') == 'true':
        return ('ci-circle', os.getcwdu() if sys.version_info < (3,) else os.getcwd())

    if os.getenv('GITHUB_ACTIONS') == 'true':
        return ('ci-github-actions', os.getenv('GITHUB_WORKSPACE'))

    return ('local', package_root) 
开发者ID:wbond,项目名称:oscrypto,代码行数:24,代码来源:coverage.py

示例2: test_basic

# 需要导入模块: import os [as 别名]
# 或者: from os import getcwdu [as 别名]
def test_basic(self):
        b = """os.getcwdu"""
        a = """os.getcwd"""
        self.check(b, a)

        b = """os.getcwdu()"""
        a = """os.getcwd()"""
        self.check(b, a)

        b = """meth = os.getcwdu"""
        a = """meth = os.getcwd"""
        self.check(b, a)

        b = """os.getcwdu(args)"""
        a = """os.getcwd(args)"""
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:18,代码来源:test_fixers.py

示例3: _do_directory

# 需要导入模块: import os [as 别名]
# 或者: from os import getcwdu [as 别名]
def _do_directory(self, make_name, chdir_name, encoded):
        if os.path.isdir(make_name):
            os.rmdir(make_name)
        os.mkdir(make_name)
        try:
            with change_cwd(chdir_name):
                if not encoded:
                    cwd_result = os.getcwdu()
                    name_result = make_name
                else:
                    cwd_result = os.getcwd().decode(TESTFN_ENCODING)
                    name_result = make_name.decode(TESTFN_ENCODING)

                cwd_result = unicodedata.normalize("NFD", cwd_result)
                name_result = unicodedata.normalize("NFD", name_result)

                self.assertEqual(os.path.basename(cwd_result),name_result)
        finally:
            os.rmdir(make_name)

    # The '_test' functions 'entry points with params' - ie, what the
    # top-level 'test' functions would be if they could take params 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:test_unicode_file.py

示例4: make_paths_absolute

# 需要导入模块: import os [as 别名]
# 或者: from os import getcwdu [as 别名]
def make_paths_absolute(pathdict, keys, base_path=None):
    """
    Interpret filesystem path settings relative to the `base_path` given.

    Paths are values in `pathdict` whose keys are in `keys`.  Get `keys` from
    `OptionParser.relative_path_settings`.
    """
    if base_path is None:
        base_path = os.getcwdu() # type(base_path) == unicode
        # to allow combining non-ASCII cwd with unicode values in `pathdict`
    for key in keys:
        if key in pathdict:
            value = pathdict[key]
            if isinstance(value, list):
                value = [make_one_path_absolute(base_path, path)
                         for path in value]
            elif value:
                value = make_one_path_absolute(base_path, value)
            pathdict[key] = value 
开发者ID:skarlekar,项目名称:faces,代码行数:21,代码来源:frontend.py

示例5: abbrev_cwd

# 需要导入模块: import os [as 别名]
# 或者: from os import getcwdu [as 别名]
def abbrev_cwd():
    """ Return abbreviated version of cwd, e.g. d:mydir """
    cwd = os.getcwdu().replace('\\','/')
    drivepart = ''
    tail = cwd
    if sys.platform == 'win32':
        if len(cwd) < 4:
            return cwd
        drivepart,tail = os.path.splitdrive(cwd)


    parts = tail.split('/')
    if len(parts) > 2:
        tail = '/'.join(parts[-2:])

    return (drivepart + (
        cwd == '/' and '/' or tail)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:process.py

示例6: setUp

# 需要导入模块: import os [as 别名]
# 或者: from os import getcwdu [as 别名]
def setUp(self):
        self.package = package = 'tmp{0}'.format(repr(random.random())[2:])
        """Temporary valid python package name."""

        self.value = int(random.random() * 10000)

        self.tempdir = TemporaryDirectory()
        self.__orig_cwd = os.getcwdu()
        sys.path.insert(0, self.tempdir.name)

        self.writefile(os.path.join(package, '__init__.py'), '')
        self.writefile(os.path.join(package, 'sub.py'), """
        x = {0!r}
        """.format(self.value))
        self.writefile(os.path.join(package, 'relative.py'), """
        from .sub import x
        """)
        self.writefile(os.path.join(package, 'absolute.py'), """
        from {0}.sub import x
        """.format(package)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:test_run.py

示例7: test_local_file_completions

# 需要导入模块: import os [as 别名]
# 或者: from os import getcwdu [as 别名]
def test_local_file_completions():
    ip = get_ipython()
    cwd = os.getcwdu()
    try:
        with TemporaryDirectory() as tmpdir:
            os.chdir(tmpdir)
            prefix = './foo'
            suffixes = map(str, [1,2])
            names = [prefix+s for s in suffixes]
            for n in names:
                open(n, 'w').close()

            # Check simple completion
            c = ip.complete(prefix)[1]
            nt.assert_equal(c, names)

            # Now check with a function call
            cmd = 'a = f("%s' % prefix
            c = ip.complete(prefix, cmd)[1]
            comp = [prefix+s for s in suffixes]
            nt.assert_equal(c, comp)
    finally:
        # prevent failures from making chdir stick
        os.chdir(cwd) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:26,代码来源:test_completer.py

示例8: test_dirops

# 需要导入模块: import os [as 别名]
# 或者: from os import getcwdu [as 别名]
def test_dirops():
    """Test various directory handling operations."""
    # curpath = lambda :os.path.splitdrive(os.getcwdu())[1].replace('\\','/')
    curpath = os.getcwdu
    startdir = os.getcwdu()
    ipdir = os.path.realpath(_ip.ipython_dir)
    try:
        _ip.magic('cd "%s"' % ipdir)
        nt.assert_equal(curpath(), ipdir)
        _ip.magic('cd -')
        nt.assert_equal(curpath(), startdir)
        _ip.magic('pushd "%s"' % ipdir)
        nt.assert_equal(curpath(), ipdir)
        _ip.magic('popd')
        nt.assert_equal(curpath(), startdir)
    finally:
        os.chdir(startdir) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:test_magic.py

示例9: cwd_filt2

# 需要导入模块: import os [as 别名]
# 或者: from os import getcwdu [as 别名]
def cwd_filt2(depth):
    """Return the last depth elements of the current working directory.

    $HOME is always replaced with '~'.
    If depth==0, the full path is returned."""

    full_cwd = os.getcwdu()
    cwd = full_cwd.replace(HOME,"~").split(os.sep)
    if '~' in cwd and len(cwd) == depth+1:
        depth += 1
    drivepart = ''
    if sys.platform == 'win32' and len(cwd) > depth:
        drivepart = os.path.splitdrive(full_cwd)[0]
    out = drivepart + '/'.join(cwd[-depth:])

    return out or os.sep

#-----------------------------------------------------------------------------
# Prompt classes
#----------------------------------------------------------------------------- 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:prompts.py

示例10: __init__

# 需要导入模块: import os [as 别名]
# 或者: from os import getcwdu [as 别名]
def __init__(self, **kwargs):
        super(BaseIPythonApplication, self).__init__(**kwargs)
        # ensure current working directory exists
        try:
            directory = os.getcwdu()
        except:
            # raise exception
            self.log.error("Current working directory doesn't exist.")
            raise

        # ensure even default IPYTHONDIR exists
        if not os.path.exists(self.ipython_dir):
            self._ipython_dir_changed('ipython_dir', self.ipython_dir, self.ipython_dir)

    #-------------------------------------------------------------------------
    # Various stages of Application creation
    #------------------------------------------------------------------------- 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:application.py

示例11: reset

# 需要导入模块: import os [as 别名]
# 或者: from os import getcwdu [as 别名]
def reset(self, new_session=True):
        """Clear the session history, releasing all object references, and
        optionally open a new session."""
        self.output_hist.clear()
        # The directory history can't be completely empty
        self.dir_hist[:] = [os.getcwdu()]
        
        if new_session:
            if self.session_number:
                self.end_session()
            self.input_hist_parsed[:] = [""]
            self.input_hist_raw[:] = [""]
            self.new_session()
    
    # ------------------------------
    # Methods for retrieving history
    # ------------------------------ 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:history.py

示例12: workflowdir

# 需要导入模块: import os [as 别名]
# 或者: from os import getcwdu [as 别名]
def workflowdir(self):
        """Path to workflow's root directory (where ``info.plist`` is).

        :returns: full path to workflow root directory
        :rtype: ``unicode``

        """
        if not self._workflowdir:
            # Try the working directory first, then the directory
            # the library is in. CWD will be the workflow root if
            # a workflow is being run in Alfred
            candidates = [
                os.path.abspath(os.getcwdu()),
                os.path.dirname(os.path.abspath(os.path.dirname(__file__)))]

            # climb the directory tree until we find `info.plist`
            for dirpath in candidates:

                # Ensure directory path is Unicode
                dirpath = self.decode(dirpath)

                while True:
                    if os.path.exists(os.path.join(dirpath, 'info.plist')):
                        self._workflowdir = dirpath
                        break

                    elif dirpath == '/':
                        # no `info.plist` found
                        break

                    # Check the parent directory
                    dirpath = os.path.dirname(dirpath)

                # No need to check other candidates
                if self._workflowdir:
                    break

            if not self._workflowdir:
                raise IOError("'info.plist' not found in directory tree")

        return self._workflowdir 
开发者ID:TKkk-iOSer,项目名称:wechat-alfred-workflow,代码行数:43,代码来源:workflow.py

示例13: workflowdir

# 需要导入模块: import os [as 别名]
# 或者: from os import getcwdu [as 别名]
def workflowdir(self):
        """Path to workflow's root directory (where ``info.plist`` is).

        Returns:
            unicode: full path to workflow root directory

        """
        if not self._workflowdir:
            # Try the working directory first, then the directory
            # the library is in. CWD will be the workflow root if
            # a workflow is being run in Alfred
            candidates = [
                os.path.abspath(os.getcwdu()),
                os.path.dirname(os.path.abspath(os.path.dirname(__file__)))]

            # climb the directory tree until we find `info.plist`
            for dirpath in candidates:

                # Ensure directory path is Unicode
                dirpath = self.decode(dirpath)

                while True:
                    if os.path.exists(os.path.join(dirpath, 'info.plist')):
                        self._workflowdir = dirpath
                        break

                    elif dirpath == '/':
                        # no `info.plist` found
                        break

                    # Check the parent directory
                    dirpath = os.path.dirname(dirpath)

                # No need to check other candidates
                if self._workflowdir:
                    break

            if not self._workflowdir:
                raise IOError("'info.plist' not found in directory tree")

        return self._workflowdir 
开发者ID:danielecook,项目名称:gist-alfred,代码行数:43,代码来源:workflow.py

示例14: test_comment

# 需要导入模块: import os [as 别名]
# 或者: from os import getcwdu [as 别名]
def test_comment(self):
        b = """os.getcwdu() # Foo"""
        a = """os.getcwd() # Foo"""
        self.check(b, a) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:6,代码来源:test_fixers.py

示例15: test_unchanged

# 需要导入模块: import os [as 别名]
# 或者: from os import getcwdu [as 别名]
def test_unchanged(self):
        s = """os.getcwd()"""
        self.unchanged(s)

        s = """getcwdu()"""
        self.unchanged(s)

        s = """os.getcwdb()"""
        self.unchanged(s) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:11,代码来源:test_fixers.py


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