Changeset 385
- Timestamp:
- 02/11/07 06:56:44 (2 years ago)
- Files:
-
- pyndexter/trunk/pyndexter/util.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pyndexter/trunk/pyndexter/util.py
r384 r385 39 39 40 40 PS. `urlparse` is not useful. 41 42 The URI constructor can be passed a string: 41 43 42 44 >>> u = URI('http://user:password@www.example.com/some/path?parm=1&parm=2&other=3#fragment') … … 58 60 'fragment' 59 61 62 ...or the individual URI components as keyword arguments: 63 64 >>> URI(scheme='http', username='user', password='password', host='www.example.com', path='/some/path', query={'parm': [1, 2], 'other': [3]}, fragment='fragment') 65 http://user:password@www.example.com/some/path?other=3&parm=1&parm=2#fragment 66 67 ...or finally, another URI object: 68 69 >>> v = URI(u) 70 >>> v == u 71 True 72 >>> v.query is u.query 73 False 74 >>> v 75 http://user:password@www.example.com/some/path?other=3&parm=1&parm=2#fragment 76 60 77 URI also normalises the path component: 61 78 … … 109 126 path = property(_get_path, _set_path) 110 127 111 def __ne__(self, other): 128 def __cmp__(self, other): 129 """Compare two URI objects. 130 131 >>> u = URI('http://user:password@www.example.com/some/path?parm=1&parm=2&other=3#fragment') 132 >>> v = URI(u) 133 >>> u == v 134 True 135 >>> v.host = 'www.google.com' 136 >>> u == v 137 False 138 """ 112 139 return cmp(repr(self), repr(other)) 113 140 … … 125 152 uri += quote(self.path) 126 153 if self.query: 127 uri += '?' + '&'.join(['&'.join(['%s=%s' % (k, quote( v)) for v in l])154 uri += '?' + '&'.join(['&'.join(['%s=%s' % (k, quote(str(v))) for v in l]) 128 155 for k, l in sorted(self.query.items())]) 129 156 if self.fragment:
