예제 #1
0
파일: local.py 프로젝트: marcosptf/fedora
 def __eq__(self, other):
     s1 = fspath(self)
     try:
         s2 = fspath(other)
     except TypeError:
         return False
     if iswin32:
         s1 = s1.lower()
         try:
             s2 = s2.lower()
         except AttributeError:
             return False
     return s1 == s2
예제 #2
0
파일: local.py 프로젝트: marcosptf/fedora
 def join(self, *args, **kwargs):
     """ return a new path by appending all 'args' as path
     components.  if abs=1 is used restart from root if any
     of the args is an absolute path.
     """
     sep = self.sep
     strargs = [fspath(arg) for arg in args]
     strpath = self.strpath
     if kwargs.get('abs'):
         newargs = []
         for arg in reversed(strargs):
             if isabs(arg):
                 strpath = arg
                 strargs = newargs
                 break
             newargs.insert(0, arg)
     for arg in strargs:
         arg = arg.strip(sep)
         if iswin32:
             # allow unix style paths even on windows.
             arg = arg.strip('/')
             arg = arg.replace('/', sep)
         strpath = strpath + sep + arg
     obj = object.__new__(self.__class__)
     obj.strpath = normpath(strpath)
     return obj
예제 #3
0
파일: local.py 프로젝트: marcosptf/fedora
 def samefile(self, other):
     """ return True if 'other' references the same file as 'self'.
     """
     other = fspath(other)
     if not isabs(other):
         other = abspath(other)
     if self == other:
         return True
     if iswin32:
         return False # there is no samefile
     return py.error.checked_call(
             os.path.samefile, self.strpath, other)
예제 #4
0
 def samefile(self, other):
     """ return True if 'other' references the same file as 'self'.
     """
     other = fspath(other)
     if not isabs(other):
         other = abspath(other)
     if self == other:
         return True
     if iswin32:
         return False # there is no samefile
     return py.error.checked_call(
             os.path.samefile, self.strpath, other)
예제 #5
0
    def __init__(self, path=None, expanduser=False):
        """ Initialize and return a local Path instance.

        Path can be relative to the current directory.
        If path is None it defaults to the current working directory.
        If expanduser is True, tilde-expansion is performed.
        Note that Path instances always carry an absolute path.
        Note also that passing in a local path object will simply return
        the exact same path object. Use new() to get a new copy.
        """
        if path is None:
            self.strpath = py.error.checked_call(os.getcwd)
        else:
            try:
                path = fspath(path)
            except TypeError:
                raise ValueError("can only pass None, Path instances "
                                 "or non-empty strings to LocalPath")
            if expanduser:
                path = os.path.expanduser(path)
            self.strpath = abspath(path)
예제 #6
0
파일: local.py 프로젝트: marcosptf/fedora
    def __init__(self, path=None, expanduser=False):
        """ Initialize and return a local Path instance.

        Path can be relative to the current directory.
        If path is None it defaults to the current working directory.
        If expanduser is True, tilde-expansion is performed.
        Note that Path instances always carry an absolute path.
        Note also that passing in a local path object will simply return
        the exact same path object. Use new() to get a new copy.
        """
        if path is None:
            self.strpath = py.error.checked_call(os.getcwd)
        else:
            try:
                path = fspath(path)
            except TypeError:
                raise ValueError("can only pass None, Path instances "
                                 "or non-empty strings to LocalPath")
            if expanduser:
                path = os.path.expanduser(path)
            self.strpath = abspath(path)
예제 #7
0
 def mkdir(self, *args):
     """ create & return the directory joined with args. """
     p = self.join(*args)
     py.error.checked_call(os.mkdir, fspath(p))
     return p
예제 #8
0
 def rename(self, target):
     """ rename this path to target. """
     target = fspath(target)
     return py.error.checked_call(os.rename, self.strpath, target)
예제 #9
0
 def __gt__(self, other):
     return fspath(self) > fspath(other)
예제 #10
0
 def __lt__(self, other):
     return fspath(self) < fspath(other)
예제 #11
0
파일: local.py 프로젝트: marcosptf/fedora
 def mkdir(self, *args):
     """ create & return the directory joined with args. """
     p = self.join(*args)
     py.error.checked_call(os.mkdir, fspath(p))
     return p
예제 #12
0
파일: local.py 프로젝트: marcosptf/fedora
 def rename(self, target):
     """ rename this path to target. """
     target = fspath(target)
     return py.error.checked_call(os.rename, self.strpath, target)
예제 #13
0
파일: local.py 프로젝트: marcosptf/fedora
 def __gt__(self, other):
     return fspath(self) > fspath(other)
예제 #14
0
파일: local.py 프로젝트: marcosptf/fedora
 def __lt__(self, other):
     return fspath(self) < fspath(other)