Ticket #2625: urlpath-quote.patch

File urlpath-quote.patch, 1.4 KB (added by taos, 5 years ago)

Added some new docstrings, removed str method in favor of toString(), not done unit tests yet.

  • twisted/python/urlpath.py

     
    3333            return result
    3434
    3535    def fromString(klass, st):
     36        """
     37        Creates a URLPath instance from the given string.
     38
     39        @type st: C{str}
     40        @param st: String for creating the object from.
     41        """
    3642        t = urlparse.urlsplit(st)
    3743        u = klass(*t)
    3844        return u
     
    4046    fromString = classmethod(fromString)
    4147
    4248    def fromRequest(klass, request):
     49        """
     50        Creates a URLPath instance from a given request.
     51        """
    4352        return klass.fromString(request.prePathURL())
    4453
    4554    fromRequest = classmethod(fromRequest)
     
    5665
    5766
    5867    def sibling(self, path, keepQuery=False):
     68        """
     69        Return a sibling to a parent.
     70
     71        @type path: C{str}
     72        @param path: The parent path for finding a sibling to.
     73        """
    5974        l = self.pathList()
    6075        l[-1] = path
    6176        return self._pathMod(l, keepQuery)
     
    127142                        query,
    128143                        fragment)
    129144
    130 
    131    
    132     def __str__(self):
     145    def toString(self):
     146        """
     147        Returns a string on the called part of URLPath
     148        """
    133149        x = urlparse.urlunsplit((
    134150            self.scheme, self.netloc, self.path,
    135151            self.query, self.fragment))