Python nt._getfinalpathname() Examples

The following are 28 code examples of nt._getfinalpathname(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module nt , or try the search function .
Example #1
Source File: pathlib.py    From PySnooper with MIT License 6 votes vote down vote up
def resolve(self, path, strict=False):
        s = str(path)
        if not s:
            return os.getcwd()
        previous_s = None
        if _getfinalpathname is not None:
            if strict:
                return self._ext_to_normal(_getfinalpathname(s))
            else:
                # End of the path after the first one not found
                tail_parts = []
                while True:
                    try:
                        s = self._ext_to_normal(_getfinalpathname(s))
                    except FileNotFoundError:
                        previous_s = s
                        s, tail = os.path.split(s)
                        tail_parts.append(tail)
                        if previous_s == s:
                            return path
                    else:
                        return os.path.join(s, *reversed(tail_parts))
        # Means fallback on absolute
        return None 
Example #2
Source File: pathlib.py    From android_universal with MIT License 6 votes vote down vote up
def resolve(self, path, strict=False):
        s = str(path)
        if not s:
            return os.getcwd()
        previous_s = None
        if _getfinalpathname is not None:
            if strict:
                return self._ext_to_normal(_getfinalpathname(s))
            else:
                tail_parts = []  # End of the path after the first one not found
                while True:
                    try:
                        s = self._ext_to_normal(_getfinalpathname(s))
                    except FileNotFoundError:
                        previous_s = s
                        s, tail = os.path.split(s)
                        tail_parts.append(tail)
                        if previous_s == s:
                            return path
                    else:
                        return os.path.join(s, *reversed(tail_parts))
        # Means fallback on absolute
        return None 
Example #3
Source File: pathlib.py    From Carnets with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def resolve(self, path, strict=False):
        s = str(path)
        if not s:
            return os.getcwd()
        previous_s = None
        if _getfinalpathname is not None:
            if strict:
                return self._ext_to_normal(_getfinalpathname(s))
            else:
                tail_parts = []  # End of the path after the first one not found
                while True:
                    try:
                        s = self._ext_to_normal(_getfinalpathname(s))
                    except FileNotFoundError:
                        previous_s = s
                        s, tail = os.path.split(s)
                        tail_parts.append(tail)
                        if previous_s == s:
                            return path
                    else:
                        return os.path.join(s, *reversed(tail_parts))
        # Means fallback on absolute
        return None 
Example #4
Source File: pathlib.py    From Imogen with MIT License 6 votes vote down vote up
def resolve(self, path, strict=False):
        s = str(path)
        if not s:
            return os.getcwd()
        previous_s = None
        if _getfinalpathname is not None:
            if strict:
                return self._ext_to_normal(_getfinalpathname(s))
            else:
                tail_parts = []  # End of the path after the first one not found
                while True:
                    try:
                        s = self._ext_to_normal(_getfinalpathname(s))
                    except FileNotFoundError:
                        previous_s = s
                        s, tail = os.path.split(s)
                        tail_parts.append(tail)
                        if previous_s == s:
                            return path
                    else:
                        return os.path.join(s, *reversed(tail_parts))
        # Means fallback on absolute
        return None 
Example #5
Source File: pathlib.py    From odoo13-x64 with GNU General Public License v3.0 6 votes vote down vote up
def resolve(self, path, strict=False):
        s = str(path)
        if not s:
            return os.getcwd()
        previous_s = None
        if _getfinalpathname is not None:
            if strict:
                return self._ext_to_normal(_getfinalpathname(s))
            else:
                tail_parts = []  # End of the path after the first one not found
                while True:
                    try:
                        s = self._ext_to_normal(_getfinalpathname(s))
                    except FileNotFoundError:
                        previous_s = s
                        s, tail = os.path.split(s)
                        tail_parts.append(tail)
                        if previous_s == s:
                            return path
                    else:
                        return os.path.join(s, *reversed(tail_parts))
        # Means fallback on absolute
        return None 
Example #6
Source File: __init__.py    From pyRevit with GNU General Public License v3.0 6 votes vote down vote up
def resolve(self, path, strict=False):
        s = str(path)
        if not s:
            return os.getcwd()
        previous_s = None
        if _getfinalpathname is not None:
            if strict:
                return self._ext_to_normal(_getfinalpathname(s))
            else:
                # End of the path after the first one not found
                tail_parts = []
                while True:
                    try:
                        s = self._ext_to_normal(_getfinalpathname(s))
                    except FileNotFoundError:
                        previous_s = s
                        s, tail = os.path.split(s)
                        tail_parts.append(tail)
                        if previous_s == s:
                            return path
                    else:
                        return os.path.join(s, *reversed(tail_parts))
        # Means fallback on absolute
        return None 
Example #7
Source File: pathlib.py    From click-configfile with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def resolve(self, path):
        s = str(path)
        if not s:
            return os.getcwd()
        if _getfinalpathname is not None:
            return self._ext_to_normal(_getfinalpathname(s))
        # Means fallback on absolute
        return None 
Example #8
Source File: test_ntpath.py    From android_universal with MIT License 5 votes vote down vote up
def test_nt_helpers(self):
        # Trivial validation that the helpers do not break, and support both
        # unicode and bytes (UTF-8) paths

        drive, path = ntpath.splitdrive(sys.executable)
        drive = drive.rstrip(ntpath.sep) + ntpath.sep
        self.assertEqual(drive, nt._getvolumepathname(sys.executable))
        self.assertEqual(drive.encode(),
                         nt._getvolumepathname(sys.executable.encode()))

        cap, free = nt._getdiskusage(sys.exec_prefix)
        self.assertGreater(cap, 0)
        self.assertGreater(free, 0)
        b_cap, b_free = nt._getdiskusage(sys.exec_prefix.encode())
        # Free space may change, so only test the capacity is equal
        self.assertEqual(b_cap, cap)
        self.assertGreater(b_free, 0)

        for path in [sys.prefix, sys.executable]:
            final_path = nt._getfinalpathname(path)
            self.assertIsInstance(final_path, str)
            self.assertGreater(len(final_path), 0)

            b_final_path = nt._getfinalpathname(path.encode())
            self.assertIsInstance(b_final_path, bytes)
            self.assertGreater(len(b_final_path), 0) 
Example #9
Source File: ntpath.py    From android_universal with MIT License 5 votes vote down vote up
def _getfinalpathname(f):
        return normcase(abspath(f)) 
Example #10
Source File: ntpath.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _getfinalpathname(f):
        return normcase(abspath(f)) 
Example #11
Source File: ntpath.py    From odoo13-x64 with GNU General Public License v3.0 5 votes vote down vote up
def _getfinalpathname(f):
        return normcase(abspath(f)) 
Example #12
Source File: ntpath.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def _getfinalpathname(f):
        return normcase(abspath(f)) 
Example #13
Source File: pathlib.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def resolve(self, path):
        s = str(path)
        if not s:
            return os.getcwd()
        if _getfinalpathname is not None:
            return self._ext_to_normal(_getfinalpathname(s))
        # Means fallback on absolute
        return None 
Example #14
Source File: ntpath.py    From python2017 with MIT License 5 votes vote down vote up
def _getfinalpathname(f):
        return normcase(abspath(f)) 
Example #15
Source File: pathlib.py    From pyRevit with GNU General Public License v3.0 5 votes vote down vote up
def resolve(self, path):
        s = str(path)
        if not s:
            return os.getcwd()
        if _getfinalpathname is not None:
            return self._ext_to_normal(_getfinalpathname(s))
        # Means fallback on absolute
        return None 
Example #16
Source File: __init__.py    From python-netsurv with MIT License 5 votes vote down vote up
def resolve(self, path, strict=False):
        s = str(path)
        if not s:
            return os.getcwd()
        previous_s = None
        if _getfinalpathname is not None:
            if strict:
                return self._ext_to_normal(_getfinalpathname(s))
            else:
                # End of the path after the first one not found
                tail_parts = []

                def _try_func():
                    result[0] = self._ext_to_normal(_getfinalpathname(s))
                    # if there was no exception, set flag to 0
                    result[1] = 0

                def _exc_func(exc):
                    pass

                while True:
                    result = [None, 1]
                    _try_except_filenotfounderror(_try_func, _exc_func)
                    if result[1] == 1:  # file not found exception raised
                        previous_s = s
                        s, tail = os.path.split(s)
                        tail_parts.append(tail)
                        if previous_s == s:
                            return path
                    else:
                        s = result[0]
                        return os.path.join(s, *reversed(tail_parts))
        # Means fallback on absolute
        return None 
Example #17
Source File: ntpath.py    From python with Apache License 2.0 5 votes vote down vote up
def _getfinalpathname(f):
        return normcase(abspath(f)) 
Example #18
Source File: ntpath.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def _getfinalpathname(f):
        return normcase(abspath(f)) 
Example #19
Source File: pathlib.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def resolve(self, path):
        s = str(path)
        if not s:
            return os.getcwd()
        if _getfinalpathname is not None:
            return self._ext_to_normal(_getfinalpathname(s))
        # Means fallback on absolute
        return None 
Example #20
Source File: ntpath.py    From scylla with Apache License 2.0 5 votes vote down vote up
def _getfinalpathname(f):
        return normcase(abspath(f)) 
Example #21
Source File: ntpath.py    From Imogen with MIT License 5 votes vote down vote up
def _getfinalpathname(f):
        return normcase(abspath(f)) 
Example #22
Source File: pathlib2.py    From pyFileFixity with MIT License 5 votes vote down vote up
def resolve(self, path):
        s = str(path)
        if not s:
            return os.getcwd()
        if _getfinalpathname is not None:
            return self._ext_to_normal(_getfinalpathname(s))
        # Means fallback on absolute
        return None 
Example #23
Source File: ntpath.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def _getfinalpathname(f):
        return normcase(abspath(f)) 
Example #24
Source File: pathlib.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def resolve(self, path):
        s = str(path)
        if not s:
            return os.getcwd()
        if _getfinalpathname is not None:
            return self._ext_to_normal(_getfinalpathname(s))
        # Means fallback on absolute
        return None 
Example #25
Source File: ntpath.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def _getfinalpathname(f):
        return normcase(abspath(f)) 
Example #26
Source File: __init__.py    From pipenv with MIT License 5 votes vote down vote up
def resolve(self, path, strict=False):
        s = str(path)
        if not s:
            return os.getcwd()
        previous_s = None
        if _getfinalpathname is not None:
            if strict:
                return self._ext_to_normal(_getfinalpathname(s))
            else:
                # End of the path after the first one not found
                tail_parts = []

                def _try_func():
                    result[0] = self._ext_to_normal(_getfinalpathname(s))
                    # if there was no exception, set flag to 0
                    result[1] = 0

                def _exc_func(exc):
                    pass

                while True:
                    result = [None, 1]
                    _try_except_filenotfounderror(_try_func, _exc_func)
                    if result[1] == 1:  # file not found exception raised
                        previous_s = s
                        s, tail = os.path.split(s)
                        tail_parts.append(tail)
                        if previous_s == s:
                            return path
                    else:
                        s = result[0]
                        return os.path.join(s, *reversed(tail_parts))
        # Means fallback on absolute
        return None 
Example #27
Source File: ntpath.py    From kobo-predict with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def _getfinalpathname(f):
        return normcase(abspath(f)) 
Example #28
Source File: __init__.py    From python-netsurv with MIT License 5 votes vote down vote up
def resolve(self, path, strict=False):
        s = str(path)
        if not s:
            return os.getcwd()
        previous_s = None
        if _getfinalpathname is not None:
            if strict:
                return self._ext_to_normal(_getfinalpathname(s))
            else:
                # End of the path after the first one not found
                tail_parts = []

                def _try_func():
                    result[0] = self._ext_to_normal(_getfinalpathname(s))
                    # if there was no exception, set flag to 0
                    result[1] = 0

                def _exc_func(exc):
                    pass

                while True:
                    result = [None, 1]
                    _try_except_filenotfounderror(_try_func, _exc_func)
                    if result[1] == 1:  # file not found exception raised
                        previous_s = s
                        s, tail = os.path.split(s)
                        tail_parts.append(tail)
                        if previous_s == s:
                            return path
                    else:
                        s = result[0]
                        return os.path.join(s, *reversed(tail_parts))
        # Means fallback on absolute
        return None