|
1 | | -import click |
| 1 | +# -*- coding: utf-8 -*- |
| 2 | + |
2 | 3 | import datetime |
3 | 4 | import json |
| 5 | +import numbers |
4 | 6 | import sys |
5 | 7 | import time |
| 8 | + |
| 9 | +import click |
6 | 10 | import yaml |
7 | | -import numbers |
8 | | -import urllib.parse |
| 11 | + |
| 12 | +try: |
| 13 | + from urllib.parse import urlsplit, urlunsplit |
| 14 | +except ImportError: # NOQA |
| 15 | + from urlparse import urlsplit, urlunsplit |
| 16 | + |
9 | 17 |
|
10 | 18 | # global state is evil! |
11 | 19 | # anyway, we are using this as a convenient hack to switch output formats |
@@ -242,7 +250,7 @@ def print_table(cols, rows, styles=None, titles=None, max_column_widths=None): |
242 | 250 | click.echo('') |
243 | 251 |
|
244 | 252 |
|
245 | | -def choice(prompt: str, options: list, default=None): |
| 253 | +def choice(prompt, options, default=None): |
246 | 254 | """ |
247 | 255 | Ask to user to select one option and return it |
248 | 256 | """ |
@@ -342,11 +350,11 @@ def convert(self, value, param, ctx): |
342 | 350 | self.fail('"{}" is not a valid URL'.format(value)) |
343 | 351 | if self.default_scheme and '://' not in value: |
344 | 352 | value = '{}://{}'.format(self.default_scheme, value) |
345 | | - url = urllib.parse.urlsplit(value) |
| 353 | + url = urlsplit(value) |
346 | 354 | if self.allowed_schemes and url.scheme not in self.allowed_schemes: |
347 | 355 | self.fail('"{}" is not one of the allowed URL schemes ({})'.format( |
348 | 356 | url.scheme, ', '.join(self.allowed_schemes))) |
349 | | - return urllib.parse.urlunsplit(url) |
| 357 | + return urlunsplit(url) |
350 | 358 |
|
351 | 359 | def __repr__(self): |
352 | 360 | return 'UrlType(%r, %r)' % (self.default_scheme, self.allowed_schemes) |
0 commit comments