48 |
47 |
49 for attr in ( |
48 for attr in ( |
50 'empty', |
49 'empty', |
51 'queue', |
50 'queue', |
52 'urlerr', |
51 'urlerr', |
53 'urlreq', |
52 # we do import urlreq, but we do it outside the loop |
|
53 #'urlreq', |
54 'stringio', |
54 'stringio', |
55 ): |
55 ): |
56 globals()[attr] = getattr(pycompat, attr) |
56 globals()[attr] = getattr(pycompat, attr) |
|
57 |
|
58 # This line is to make pyflakes happy: |
|
59 urlreq = pycompat.urlreq |
57 |
60 |
58 if os.name == 'nt': |
61 if os.name == 'nt': |
59 from . import windows as platform |
62 from . import windows as platform |
60 else: |
63 else: |
61 from . import posix as platform |
64 from . import posix as platform |
2386 or hasdriveletter(self.path)): |
2389 or hasdriveletter(self.path)): |
2387 s += '//' |
2390 s += '//' |
2388 if hasdriveletter(self.path): |
2391 if hasdriveletter(self.path): |
2389 s += '/' |
2392 s += '/' |
2390 if self.user: |
2393 if self.user: |
2391 s += urllib.quote(self.user, safe=self._safechars) |
2394 s += urlreq.quote(self.user, safe=self._safechars) |
2392 if self.passwd: |
2395 if self.passwd: |
2393 s += ':' + urllib.quote(self.passwd, safe=self._safechars) |
2396 s += ':' + urlreq.quote(self.passwd, safe=self._safechars) |
2394 if self.user or self.passwd: |
2397 if self.user or self.passwd: |
2395 s += '@' |
2398 s += '@' |
2396 if self.host: |
2399 if self.host: |
2397 if not (self.host.startswith('[') and self.host.endswith(']')): |
2400 if not (self.host.startswith('[') and self.host.endswith(']')): |
2398 s += urllib.quote(self.host) |
2401 s += urlreq.quote(self.host) |
2399 else: |
2402 else: |
2400 s += self.host |
2403 s += self.host |
2401 if self.port: |
2404 if self.port: |
2402 s += ':' + urllib.quote(self.port) |
2405 s += ':' + urlreq.quote(self.port) |
2403 if self.host: |
2406 if self.host: |
2404 s += '/' |
2407 s += '/' |
2405 if self.path: |
2408 if self.path: |
2406 # TODO: similar to the query string, we should not unescape the |
2409 # TODO: similar to the query string, we should not unescape the |
2407 # path when we store it, the path might contain '%2f' = '/', |
2410 # path when we store it, the path might contain '%2f' = '/', |
2408 # which we should *not* escape. |
2411 # which we should *not* escape. |
2409 s += urllib.quote(self.path, safe=self._safepchars) |
2412 s += urlreq.quote(self.path, safe=self._safepchars) |
2410 if self.query: |
2413 if self.query: |
2411 # we store the query in escaped form. |
2414 # we store the query in escaped form. |
2412 s += '?' + self.query |
2415 s += '?' + self.query |
2413 if self.fragment is not None: |
2416 if self.fragment is not None: |
2414 s += '#' + urllib.quote(self.fragment, safe=self._safepchars) |
2417 s += '#' + urlreq.quote(self.fragment, safe=self._safepchars) |
2415 return s |
2418 return s |
2416 |
2419 |
2417 def authinfo(self): |
2420 def authinfo(self): |
2418 user, passwd = self.user, self.passwd |
2421 user, passwd = self.user, self.passwd |
2419 try: |
2422 try: |