Skip to content
This repository was archived by the owner on Oct 3, 2020. It is now read-only.

Commit 0edd2b5

Browse files
authored
Merge pull request #9 from rafaelcaricio/support-python2.7
Support Python 2.7
2 parents 87826cf + 445dfe9 commit 0edd2b5

7 files changed

Lines changed: 55 additions & 33 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ coverage.xml
77
.coverage
88
htmlcov
99
.cache
10+
.tox/

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
language: python
22
python:
3+
- "pypy"
4+
- "2.7"
35
- "3.4"
46
- "3.5"
57
install:
6-
- pip install -r requirements.txt
7-
- pip install coveralls flake8
8+
- pip install tox tox-travis coveralls
89
script:
9-
- python setup.py test
10-
- flake8 .
10+
- tox
1111
after_success:
1212
- coveralls

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ See this `example script`_ and the `shell script`_.
9393
::
9494

9595
$ ./example.py li
96-
IdentifierName Status Creation DateDescription Without Title
96+
Identifier|Name |Status |Creation Date|Description |Without Title
9797
0 Column #0 ERROR -4228033s ago this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr.. column without title
9898
1 Column #1 FINE -4228033s ago this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr.. column without title
9999
2 Column #2 WARNING -4228033s ago this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr.. column without title
@@ -188,7 +188,7 @@ See this `example script`_ and the `shell script`_.
188188
This is a ok with message:all is fine
189189
This is a warning: please check this
190190
Start with working.. . . . . OK
191-
IdName
191+
Id|Name
192192
1 Test #1
193193
2 Test #2
194194
Only FYI
@@ -220,7 +220,7 @@ See this `example script`_ and the `shell script`_.
220220
License
221221
=======
222222

223-
Copyright © 2015 Zalando SE
223+
Copyright (c) 2015 Zalando SE
224224

225225
Licensed under the Apache License, Version 2.0 (the "License");
226226
you may not use this file except in compliance with the License.

clickclick/console.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
import click
1+
# -*- coding: utf-8 -*-
2+
23
import datetime
34
import json
5+
import numbers
46
import sys
57
import time
8+
9+
import click
610
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+
917

1018
# global state is evil!
1119
# 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):
242250
click.echo('')
243251

244252

245-
def choice(prompt: str, options: list, default=None):
253+
def choice(prompt, options, default=None):
246254
"""
247255
Ask to user to select one option and return it
248256
"""
@@ -342,11 +350,11 @@ def convert(self, value, param, ctx):
342350
self.fail('"{}" is not a valid URL'.format(value))
343351
if self.default_scheme and '://' not in value:
344352
value = '{}://{}'.format(self.default_scheme, value)
345-
url = urllib.parse.urlsplit(value)
353+
url = urlsplit(value)
346354
if self.allowed_schemes and url.scheme not in self.allowed_schemes:
347355
self.fail('"{}" is not one of the allowed URL schemes ({})'.format(
348356
url.scheme, ', '.join(self.allowed_schemes)))
349-
return urllib.parse.urlunsplit(url)
357+
return urlunsplit(url)
350358

351359
def __repr__(self):
352360
return 'UrlType(%r, %r)' % (self.default_scheme, self.allowed_schemes)

setup.py

100644100755
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ def get_install_requirements(path):
9595

9696

9797
def read(fname):
98-
return open(os.path.join(__location__, fname), encoding='utf-8').read()
98+
with open(os.path.join(__location__, fname)) as readme:
99+
return readme.read()
99100

100101

101102
def check_deps(deps):

tests/test_console.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
1+
# -*- coding: utf-8 -*-
2+
13
import datetime
2-
import pytest
34
import time
45

56
import click
6-
77
from click.testing import CliRunner
8-
from clickclick import (
9-
Action,
10-
action,
11-
AliasedGroup,
12-
choice,
13-
error,
14-
fatal_error,
15-
FloatRange,
16-
format_time,
17-
info,
18-
ok,
19-
OutputFormat,
20-
print_table,
21-
UrlType,
22-
warning,
23-
)
8+
from clickclick import (Action, AliasedGroup, FloatRange, OutputFormat,
9+
UrlType, action, choice, error, fatal_error,
10+
format_time, info, ok, print_table, warning)
11+
12+
import pytest
2413

2514

2615
def test_echo():
@@ -93,7 +82,7 @@ def test_text_out(capsys):
9382
warning('this is a warning')
9483
print_table('a b'.split(), [{}, {}])
9584
out, err = capsys.readouterr()
96-
assert 'A│B\n \n \n' == out
85+
assert u'A│B\n \n \n' == out
9786
assert 'this is a warning\n' == err
9887

9988

tox.ini

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
11
[flake8]
22
max-line-length=120
3+
4+
[tox]
5+
envlist=pypy,py27,py34,py35,isort-check,flake8
6+
7+
[tox:travis]
8+
pypy=pypy
9+
2.7=py27
10+
3.4=py34
11+
3.5=py35,isort-check,flake8
12+
13+
[testenv]
14+
commands=python setup.py test
15+
16+
[testenv:flake8]
17+
deps=flake8
18+
commands=python setup.py flake8
19+
20+
[testenv:isort-check]
21+
basepython=python3
22+
deps=isort
23+
commands=isort -ns __init__.py -rc -c -df {toxinidir}/clickclick {toxinidir}/tests
24+
25+

0 commit comments

Comments
 (0)