コード例 #1
0
ファイル: test_nt.py プロジェクト: IronLanguages/ironpython2
 def test__getfullpathname(self):
     self.assertEqual(nt._getfullpathname('.'), nt.getcwd())
     self.assertEqual(nt._getfullpathname('<bad>'), os.path.join(nt.getcwd(), '<bad>'))
     self.assertEqual(nt._getfullpathname('bad:'), os.path.join(nt.getcwd(), 'bad:'))
     self.assertEqual(nt._getfullpathname(':bad:'), os.path.join(nt.getcwd(), ':bad:'))
     self.assertEqual(nt._getfullpathname('::'), '::\\')
     self.assertEqual(nt._getfullpathname('1:'), '1:\\')
     self.assertEqual(nt._getfullpathname('1:a'), '1:\\a')
     self.assertEqual(nt._getfullpathname('1::'), '1:\\:')
     self.assertEqual(nt._getfullpathname('1:\\'), '1:\\')
コード例 #2
0
 def test__getfullpathname(self):
     self.assertEqual(nt._getfullpathname('.'), nt.getcwd())
     self.assertEqual(nt._getfullpathname('<bad>'), os.path.join(nt.getcwd(), '<bad>'))
     self.assertEqual(nt._getfullpathname('bad:'), os.path.join(nt.getcwd(), 'bad:'))
     self.assertEqual(nt._getfullpathname(':bad:'), os.path.join(nt.getcwd(), ':bad:'))
     self.assertEqual(nt._getfullpathname('::'), '::\\')
     self.assertEqual(nt._getfullpathname('1:'), '1:\\')
     self.assertEqual(nt._getfullpathname('1:a'), '1:\\a')
     self.assertEqual(nt._getfullpathname('1::'), '1:\\:')
     self.assertEqual(nt._getfullpathname('1:\\'), '1:\\')
コード例 #3
0
ファイル: nt_test.py プロジェクト: 89sos98/main
def test__getfullpathname():
    AreEqual(nt._getfullpathname('.'), nt.getcwd())
    AreEqual(nt._getfullpathname('<bad>'), path_combine(nt.getcwd(), '<bad>'))
    AreEqual(nt._getfullpathname('bad:'), path_combine(nt.getcwd(), 'bad:'))
    AreEqual(nt._getfullpathname(':bad:'), path_combine(nt.getcwd(), ':bad:'))
    AreEqual(nt._getfullpathname('::'), '::\\')
    AreEqual(nt._getfullpathname('1:'), '1:\\')
    AreEqual(nt._getfullpathname('1:a'), '1:\\a')
    AreEqual(nt._getfullpathname('1::'), '1:\\:')
    AreEqual(nt._getfullpathname('1:\\'), '1:\\')
コード例 #4
0
ファイル: nt_test.py プロジェクト: slide/main
def test__getfullpathname():
    AreEqual(nt._getfullpathname("."), nt.getcwd())
    AreEqual(nt._getfullpathname("<bad>"), path_combine(nt.getcwd(), "<bad>"))
    AreEqual(nt._getfullpathname("bad:"), path_combine(nt.getcwd(), "bad:"))
    AreEqual(nt._getfullpathname(":bad:"), path_combine(nt.getcwd(), ":bad:"))
    AreEqual(nt._getfullpathname("::"), "::\\")
    AreEqual(nt._getfullpathname("1:"), "1:\\")
    AreEqual(nt._getfullpathname("1:a"), "1:\\a")
    AreEqual(nt._getfullpathname("1::"), "1:\\:")
    AreEqual(nt._getfullpathname("1:\\"), "1:\\")
コード例 #5
0
ファイル: nt_test.py プロジェクト: zmqcherish/ironpython3
def test__getfullpathname():
    AreEqual(nt._getfullpathname('.'), nt.getcwd())
    AreEqual(nt._getfullpathname('<bad>'), path_combine(nt.getcwd(), '<bad>'))
    AreEqual(nt._getfullpathname('bad:'), path_combine(nt.getcwd(), 'bad:'))
    AreEqual(nt._getfullpathname(':bad:'), path_combine(nt.getcwd(), ':bad:'))
    AreEqual(nt._getfullpathname('::'), '::\\')
    AreEqual(nt._getfullpathname('1:'), '1:\\')
    AreEqual(nt._getfullpathname('1:a'), '1:\\a')
    AreEqual(nt._getfullpathname('1::'), '1:\\:')
    AreEqual(nt._getfullpathname('1:\\'), '1:\\')
コード例 #6
0
ファイル: utils.py プロジェクト: be-engineer/winpdb
def my_abspath1(path):
    """
    Modification of ntpath.abspath() that avoids doing an import.
    """

    if path:
        try:
            path = _getfullpathname(path)
        except WindowsError:
            pass
    else:
        try:
            path = getcwd()

        except UnicodeDecodeError:
            #
            # This exception can be raised in py3k (alpha) on nt.
            #
            path = getcwdu()

    np = os.path.normpath(path)

    if (len(np) >= 2) and (np[1:2] == ':'):
        np = np[:1].upper() + np[1:]

    return np
コード例 #7
0
ファイル: fileutil.py プロジェクト: tahoe-lafs/tahoe-lafs
def abspath_expanduser_unicode(path, base=None, long_path=True):
    """
    Return the absolute version of a path. If 'base' is given and 'path' is relative,
    the path will be expanded relative to 'base'.
    'path' must be a Unicode string. 'base', if given, must be a Unicode string
    corresponding to an absolute path as returned by a previous call to
    abspath_expanduser_unicode.
    On Windows, the result will be a long path unless long_path is given as False.
    """
    if not isinstance(path, str):
        raise AssertionError("paths must be Unicode strings")
    if base is not None and long_path:
        precondition_abspath(base)

    path = expanduser(path)

    if _getfullpathname:
        # On Windows, os.path.isabs will incorrectly return True
        # for paths without a drive letter (that are not UNC paths),
        # e.g. "\\". See <http://bugs.python.org/issue1669539>.
        try:
            if base is None:
                path = _getfullpathname(path or u".")
            else:
                path = _getfullpathname(os.path.join(base, path))
        except OSError:
            pass

    if not os.path.isabs(path):
        if base is None:
            cwd = os.getcwd()
            if PY2:
                cwd = cwd.decode('utf8')
            path = os.path.join(cwd, path)
        else:
            path = os.path.join(base, path)

    # We won't hit <http://bugs.python.org/issue5827> because
    # there is always at least one Unicode path component.
    path = os.path.normpath(path)

    if sys.platform == "win32" and long_path:
        path = to_windows_long_path(path)

    return path
コード例 #8
0
ファイル: fileutil.py プロジェクト: tahoe-lafs/tahoe-lafs
def abspath_expanduser_unicode(path, base=None, long_path=True):
    """
    Return the absolute version of a path. If 'base' is given and 'path' is relative,
    the path will be expanded relative to 'base'.
    'path' must be a Unicode string. 'base', if given, must be a Unicode string
    corresponding to an absolute path as returned by a previous call to
    abspath_expanduser_unicode.
    On Windows, the result will be a long path unless long_path is given as False.
    """
    if not isinstance(path, unicode):
        raise AssertionError("paths must be Unicode strings")
    if base is not None and long_path:
        precondition_abspath(base)

    path = expanduser(path)

    if _getfullpathname:
        # On Windows, os.path.isabs will incorrectly return True
        # for paths without a drive letter (that are not UNC paths),
        # e.g. "\\". See <http://bugs.python.org/issue1669539>.
        try:
            if base is None:
                path = _getfullpathname(path or u".")
            else:
                path = _getfullpathname(os.path.join(base, path))
        except OSError:
            pass

    if not os.path.isabs(path):
        if base is None:
            path = os.path.join(os.getcwdu(), path)
        else:
            path = os.path.join(base, path)

    # We won't hit <http://bugs.python.org/issue5827> because
    # there is always at least one Unicode path component.
    path = os.path.normpath(path)

    if sys.platform == "win32" and long_path:
        path = to_windows_long_path(path)

    return path
コード例 #9
0
ファイル: ntpath.py プロジェクト: johndpope/sims4-ai-engine
def abspath(path):
    if path:
        try:
            path = _getfullpathname(path)
        except WindowsError:
            pass
    elif isinstance(path, bytes):
        path = os.getcwdb()
    else:
        path = os.getcwd()
    return normpath(path)
コード例 #10
0
def abspath(path):
    if path:
        try:
            path = _getfullpathname(path)
        except WindowsError:
            pass
    elif isinstance(path, bytes):
        path = os.getcwdb()
    else:
        path = os.getcwd()
    return normpath(path)
コード例 #11
0
    def abspath(path):
        """Return the absolute version of a path."""

        if path: # Empty path must return current working directory.
            try:
                path = _getfullpathname(path)
            except WindowsError:
                pass # Bad path - return unchanged.
        else:
            path = os.getcwd()
        return normpath(path)
コード例 #12
0
ファイル: ntpath.py プロジェクト: movermeyer/nametrans
    def abspath(path):
        """Return the absolute version of a path."""

        if path:  # Empty path must return current working directory.
            try:
                path = _getfullpathname(path)
            except WindowsError:
                pass  # Bad path - return unchanged.
        else:
            path = os.getcwd()
        return normpath(path)
コード例 #13
0
ファイル: ntpath.py プロジェクト: webiumsk/WOT-0.9.12
    def abspath(path):
        """Return the absolute version of a path."""
        if path:
            try:
                path = _getfullpathname(path)
            except WindowsError:
                pass

        elif isinstance(path, unicode):
            path = os.getcwdu()
        else:
            path = os.getcwd()
        return normpath(path)
コード例 #14
0
ファイル: ntpath.py プロジェクト: emilyemorehouse/ast-and-me
 def abspath(path):
     """Return the absolute version of a path."""
     if path:
         path = os.fspath(path)
         try:
             path = _getfullpathname(path)
         except OSError:
             pass
     elif isinstance(path, bytes):
         path = os.getcwdb()
     else:
         path = os.getcwd()
     return normpath(path)
コード例 #15
0
    def abspath(path):
        """Return the absolute version of a path."""
        if path:
            try:
                path = _getfullpathname(path)
            except WindowsError:
                pass

        elif isinstance(path, unicode):
            path = os.getcwdu()
        else:
            path = os.getcwd()
        return normpath(path)
コード例 #16
0
    def abspath(path):
        """Return the absolute version of a path."""

        if path: # Empty path must return current working directory.
            path = os.fspath(path)
            try:
                path = _getfullpathname(path)
            except OSError:
                pass # Bad path - return unchanged.
        elif isinstance(path, bytes):
            path = os.getcwdb()
        else:
            path = os.getcwd()
        return normpath(path)
コード例 #17
0
ファイル: ntpath.py プロジェクト: adUst0/FixSubs
    def abspath(path):
        """Return the absolute version of a path."""

        if path:  # Empty path must return current working directory.
            path = os.fspath(path)
            try:
                path = _getfullpathname(path)
            except OSError:
                pass  # Bad path - return unchanged.
        elif isinstance(path, bytes):
            path = os.getcwdb()
        else:
            path = os.getcwd()
        return normpath(path)
コード例 #18
0
ファイル: __init__.py プロジェクト: 6131866021/js_test
    def __init__(self,
                 name,
                 mode=DEFAULT_MODE,
                 handle=None,
                 use_errno=False,
                 use_last_error=False,
                 winmode=None):
        self._name = name
        flags = self._func_flags_
        if use_errno:
            flags |= _FUNCFLAG_USE_ERRNO
        if use_last_error:
            flags |= _FUNCFLAG_USE_LASTERROR
        if _sys.platform.startswith("aix"):
            """When the name contains ".a(" and ends with ")",
               e.g., "libFOO.a(libFOO.so)" - this is taken to be an
               archive(member) syntax for dlopen(), and the mode is adjusted.
               Otherwise, name is presented to dlopen() as a file argument.
            """
            if name and name.endswith(")") and ".a(" in name:
                mode |= (_os.RTLD_MEMBER | _os.RTLD_NOW)
        if _os.name == "nt":
            if winmode is not None:
                mode = winmode
            else:
                import nt
                mode = nt._LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
                if '/' in name or '\\' in name:
                    self._name = nt._getfullpathname(self._name)
                    mode |= nt._LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
                # PATH is how DLL lookup has always worked in the past
                # in Python on Windows. IMHO both the above mode flags
                # are not wanted and should have been seen as serious
                # regressions to Python on Windows. We should however
                # propagate any PATH changes that have happened to Python
                # library and that is not yet implemented.
                LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008
                mode = LOAD_WITH_ALTERED_SEARCH_PATH

        class _FuncPtr(_CFuncPtr):
            _flags_ = flags
            _restype_ = self._func_restype_

        self._FuncPtr = _FuncPtr

        if handle is None:
            self._handle = _dlopen(self._name, mode)
        else:
            self._handle = handle
コード例 #19
0
    def __init__(self,
                 name,
                 mode=DEFAULT_MODE,
                 handle=None,
                 use_errno=False,
                 use_last_error=False,
                 winmode=None):
        self._name = name
        flags = self._func_flags_
        if use_errno:
            flags |= _FUNCFLAG_USE_ERRNO
        if use_last_error:
            flags |= _FUNCFLAG_USE_LASTERROR
        if _sys.platform.startswith("aix"):
            """When the name contains ".a(" and ends with ")",
               e.g., "libFOO.a(libFOO.so)" - this is taken to be an
               archive(member) syntax for dlopen(), and the mode is adjusted.
               Otherwise, name is presented to dlopen() as a file argument.
            """
            if name and name.endswith(")") and ".a(" in name:
                mode |= (_os.RTLD_MEMBER | _os.RTLD_NOW)
        if _os.name == "nt":
            if winmode is not None:
                mode = winmode
            else:
                import nt
                mode = nt._LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
                if '/' in name or '\\' in name:
                    self._name = nt._getfullpathname(self._name)
                    mode |= nt._LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR

        class _FuncPtr(_CFuncPtr):
            _flags_ = flags
            _restype_ = self._func_restype_

        self._FuncPtr = _FuncPtr

        self._builtin = {}

        if handle is None:
            if isinstance(self._name, dict):
                self._builtin = self._name['symbols']
                self._name = self._name['name']
                self._handle = 0
            else:
                self._handle = _dlopen(self._name, mode)
        else:
            self._handle = handle
コード例 #20
0
ファイル: fileutil.py プロジェクト: p-static/tahoe-lafs
def abspath_expanduser_unicode(path):
    """Return the absolute version of a path."""
    assert isinstance(path, unicode), path

    path = os.path.expanduser(path)

    if _getfullpathname:
        # On Windows, os.path.isabs will return True for paths without a drive letter,
        # e.g. "\\". See <http://bugs.python.org/issue1669539>.
        try:
            path = _getfullpathname(path or u".")
        except OSError:
            pass

    if not os.path.isabs(path):
        path = os.path.join(os.getcwdu(), path)

    # We won't hit <http://bugs.python.org/issue5827> because
    # there is always at least one Unicode path component.
    return os.path.normpath(path)
コード例 #21
0
ファイル: fileutil.py プロジェクト: isnotajoke/tahoe-lafs
def abspath_expanduser_unicode(path):
    """Return the absolute version of a path."""
    assert isinstance(path, unicode), path

    path = os.path.expanduser(path)

    if _getfullpathname:
        # On Windows, os.path.isabs will return True for paths without a drive letter,
        # e.g. "\\". See <http://bugs.python.org/issue1669539>.
        try:
            path = _getfullpathname(path or u".")
        except OSError:
            pass

    if not os.path.isabs(path):
        path = os.path.join(os.getcwdu(), path)

    # We won't hit <http://bugs.python.org/issue5827> because
    # there is always at least one Unicode path component.
    return os.path.normpath(path)
コード例 #22
0
ファイル: ntpath.py プロジェクト: pemby/breve
def abspath(path):
    """Return the absolute version of a path"""
    try:
        from nt import _getfullpathname
    except ImportError: # Not running on Windows - mock up something sensible.
        global abspath
        def _abspath(path):
            if not isabs(path):
                path = join(os.getcwd(), path)
            return normpath(path)
        abspath = _abspath
        return _abspath(path)

    if path: # Empty path must return current working directory.
        try:
            path = _getfullpathname(path)
        except WindowsError:
            pass # Bad path - return unchanged.
    else:
        path = os.getcwd()
    return normpath(path)
コード例 #23
0
ファイル: ntpath.py プロジェクト: vata/prebcwow
def abspath(path):
    """Return the absolute version of a path"""
    try:
        from nt import _getfullpathname
    except ImportError: # Not running on Windows - mock up something sensible.
        global abspath
        def _abspath(path):
            if not isabs(path):
                path = join(os.getcwd(), path)
            return normpath(path)
        abspath = _abspath
        return _abspath(path)

    if path: # Empty path must return current working directory.
        try:
            path = _getfullpathname(path)
        except WindowsError:
            pass # Bad path - return unchanged.
    else:
        path = os.getcwd()
    return normpath(path)
コード例 #24
0
ファイル: ntpath.py プロジェクト: kenashley2002/crawler
 def abspath(path):
     """Return the absolute version of a path."""
     try:
         return _getfullpathname(path)
     except OSError:
         return _abspath_fallback(path)
コード例 #25
0
import clr
import shutil
clr.AddReference("System.Xml")

from System.Xml import XmlDocument, XmlNamespaceManager
from System import Guid
from System.IO import File, Path, Directory, FileInfo, FileAttributes

#List of predetermined directories and files which should not be included in
#the MSI
excludedDirectories = []
excludedFiles = []

#Automatically determine what's currently not working under IronPython
sys.path.append(nt.environ["DLR_ROOT"] + r"\Languages\IronPython\Tests\Tools")
base_dir = nt._getfullpathname(
    nt.environ["DLR_ROOT"] + r"\External.LCA_RESTRICTED\Languages\CPython\27")

import stdmodules
BROKEN_LIST = stdmodules.main(base_dir)

if len(BROKEN_LIST) < 10:
    #If there are less than ten modules/directories listed in BROKEN_LIST
    #chances are good stdmodules is broken!
    exc_msg = "It's highly unlikely that only %d CPy standard modules are broken under IP!" % len(
        BROKEN_LIST)
    print exc_msg
    raise Exception(exc_msg)

#Specify Packages and Modules that should not be included here.
excludedDirectories += [
    "/Lib/test",
コード例 #26
0
 def abspath(self):
     from nt import _getfullpathname
     return NTPath(_getfullpathname(str(self)))
コード例 #27
0
ファイル: path_nr.py プロジェクト: binaryphile/Unipath
 def abspath(self):
     from nt import _getfullpathname
     return NTPath(_getfullpathname(str(self)))
コード例 #28
0
 def abspath(path):
     """Return the absolute version of a path."""
     try:
         return _getfullpathname(path)
     except (OSError, ValueError):
         return _abspath_fallback(path)
コード例 #29
0
ファイル: ntpath.py プロジェクト: willingc/cpython
 def abspath(path):
     """Return the absolute version of a path."""
     try:
         return normpath(_getfullpathname(path))
     except (OSError, ValueError):
         return _abspath_fallback(path)
コード例 #30
0
ファイル: ntpath.py プロジェクト: mcyril/ravel-ftn
# Module 'ntpath' -- common operations on WinNT/Win95 pathnames
コード例 #31
0
ファイル: MakeModuleList.py プロジェクト: BillyboyD/main
import shutil
clr.AddReference("System.Xml")

from System.Xml import XmlDocument, XmlNamespaceManager
from System import Guid
from System.IO import File, Path, Directory, FileInfo, FileAttributes

#List of predetermined directories and files which should not be included in
#the MSI
excludedDirectories = []
excludedFiles       = []


#Automatically determine what's currently not working under IronPython
sys.path.append(nt.environ["DLR_ROOT"] + r"\Languages\IronPython\Tests\Tools")
base_dir = nt._getfullpathname(nt.environ["DLR_ROOT"] + r"\External.LCA_RESTRICTED\Languages\CPython\27")

import stdmodules
BROKEN_LIST = stdmodules.main(base_dir)

if len(BROKEN_LIST)<10:
    #If there are less than ten modules/directories listed in BROKEN_LIST
    #chances are good stdmodules is broken!
    exc_msg = "It's highly unlikely that only %d CPy standard modules are broken under IP!" % len(BROKEN_LIST)
    print exc_msg
    raise Exception(exc_msg)

#Specify Packages and Modules that should not be included here.
excludedDirectories += [
                        "/Lib/test",
                        "/Lib/idlelib",
コード例 #32
0
ファイル: rposix.py プロジェクト: njues/Sypy
 def _getfullpathname(path):
     if isinstance(path, str):
         return nt._getfullpathname(path)
     else:
         return nt._getfullpathname(path.as_bytes())
コード例 #33
0
ファイル: rposix.py プロジェクト: zielmicha/pypy
 def _getfullpathname(path):
     return nt._getfullpathname(_as_bytes(path))
コード例 #34
0
ファイル: rposix.py プロジェクト: ParitoshThapliyal59/pypy
 def _getfullpathname(path):
     if isinstance(path, str):
         return nt._getfullpathname(path)
     else:
         return nt._getfullpathname(path.as_bytes())
コード例 #35
0
ファイル: rposix.py プロジェクト: bukzor/pypy
 def _getfullpathname(path):
     return nt._getfullpathname(_as_bytes(path))