Skip to content

Commit 3496dbc

Browse files
authored
Merge pull request #293 from nexB/291-280-python3-support
Python3 support
2 parents b1d917a + 0629a1d commit 3496dbc

File tree

123 files changed

+2371
-804
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+2371
-804
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ language: python
22

33
python:
44
- "2.7"
5+
- "3.6"
56

67
install:
78
- ./configure etc/conf/dev

MANIFEST.in

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
1-
include *.ABOUT
2-
include about*
3-
include *LICENSE*
4-
include *NOTICE*
5-
include *README*
1+
graft src
2+
graft tests
3+
graft docs
4+
graft etc
5+
graft example
6+
graft thirdparty
7+
8+
prune src/aboutcode_toolkit.egg-info
9+
10+
include about.ABOUT
11+
include about
12+
include about.bat
13+
include about.cfg
14+
include apache-2.0.LICENSE
15+
include about.bat
16+
include apache-2.0.LICENSE
17+
include configure
18+
include configure.bat
19+
include MANIFEST.in
20+
include NOTICE
21+
include README.rst
22+
include setup.cfg
23+
include setup.py
24+
include SPEC
625
include USAGE.rst
7-
include *SPEC*
26+
include .travis.yml
27+
include appveyor.yml
828

9-
recursive-include tests/testdata *
10-
recursive-include about_code_tool/templates *
29+
global-exclude *.py[co] __pycache__ *.*~

README.rst

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
AboutCode toolkit
22
=================
33

4-
.. image:: https://api.travis-ci.org/nexB/aboutcode-toolkit.png?branch=develop
5-
:target: https://travis-ci.org/nexB/aboutcode-toolkit
6-
7-
.. image:: https://coveralls.io/repos/nexB/aboutcode-toolkit/badge.png?branch=develop
8-
:target: https://coveralls.io/r/nexB/aboutcode-toolkit?branch=develop
4+
Build and tests status
5+
----------------------
6+
7+
+-------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+
8+
|Branch | **Linux (Travis)** | **MacOSX (Travis)** | **Windows (AppVeyor)** |
9+
+=======+===============================================================================+===============================================================================+======================================================================================================+
10+
| |.. image:: https://api.travis-ci.org/nexB/aboutcode-toolkit.png?branch=master |.. image:: https://api.travis-ci.org/nexB/aboutcode-toolkit.png?branch=master |.. image:: https://ci.appveyor.com/api/projects/status/nexB/aboutcode-toolkit/branch/master?png=true |
11+
|Master | :target: https://travis-ci.org/nexB/aboutcode-toolkit | :target: https://travis-ci.org/nexB/aboutcode-toolkit | :target: https://ci.appveyor.com/project/nexB/aboutcode-toolkit |
12+
| | :alt: Linux Master branch tests status | :alt: MacOSX Master branch tests status | :alt: Windows Master branch tests status |
13+
+-------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+
14+
| |.. image:: https://api.travis-ci.org/nexB/aboutcode-toolkit.png?branch=develop |.. image:: https://api.travis-ci.org/nexB/aboutcode-toolkit.png?branch=develop |.. image:: https://ci.appveyor.com/api/projects/status/nexB/aboutcode-toolkit/branch/develop?png=true |
15+
|Develop| :target: https://travis-ci.org/nexB/aboutcode-toolkit | :target: https://travis-ci.org/nexB/aboutcode-toolkit | :target: https://ci.appveyor.com/project/nexB/aboutcode-toolkit |
16+
| | :alt: Linux Develop branch tests status | :alt: MacOSX Develop branch tests status | :alt: Windows Develop branch tests status |
17+
+-------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+
918

1019

1120
The AboutCode toolkit and ABOUT files provide a simple way to document the
@@ -32,17 +41,16 @@ https://github.com/nexB/aboutcode-toolkit/blob/master/SPEC
3241

3342
REQUIREMENTS
3443
------------
35-
The AboutCode toolkit is tested with 2.7 on Linux, Mac and Windows.
44+
The AboutCode toolkit is tested with Python 2.7 and 3.6 on Linux, Mac and Windows.
3645
You will need to install a Python interpreter if you do not have one already
3746
installed.
3847

3948
On Linux and Mac, Python is typically pre-installed. To verify which
4049
version may be pre-installed, open a terminal and type::
4150

4251
python --version
43-
python2.7 --version
4452

45-
On Windows or Mac, you can download the latest Python 2.7.x here:
53+
On Windows or Mac, you can download the latest Python here:
4654
https://www.python.org/downloads/
4755

4856
Download the .msi installer for Windows or the .dmg archive for Mac.
@@ -55,7 +63,7 @@ Checkout or download and extract the AboutCode toolkit from:
5563
https://github.com/nexB/aboutcode-toolkit/
5664

5765
To install all the needed dependencies in a virtualenv, run (on posix)::
58-
source configure
66+
source configure
5967
or on windows::
6068
configure
6169

@@ -65,8 +73,8 @@ USAGE
6573
See https://github.com/nexB/aboutcode-toolkit/blob/master/USAGE.rst for USAGE.
6674

6775

68-
TESTS and DEVLOPMENT
69-
--------------------
76+
TESTS and DEVELOPMENT
77+
---------------------
7078
To install all the needed development dependencies, run (on posix)::
7179
source configure etc/conf/dev
7280
or on windows::
@@ -76,7 +84,6 @@ To verify that everything works fine you can run the test suite with::
7684
py.test
7785

7886

79-
8087
HELP and SUPPORT
8188
----------------
8289
If you have a question or find a bug, enter a ticket at:

about.ABOUT

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
about_resource: .
22

3-
name: AboutCode
4-
version: 3.0.0.dev4
3+
name: AboutCode-toolkit
4+
version: 3.0.0.dev6
55

66
owner: nexB Inc.
77
author: Jillian Daguil, Chin Yeung Li, Philippe Ombredanne, Thomas Druez
88

9-
home_url: http://dejacode.org
9+
home_url: https://aboutcode.org
1010

1111
vcs_tool: git
1212
vcs_repository: https://github.com/dejacode/about-code-tool.git

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fi
2727

2828
CONFIGURE_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2929

30-
python2.7 $CONFIGURE_ROOT_DIR/etc/configure.py $CFG_CMD_LINE_ARGS
30+
python $CONFIGURE_ROOT_DIR/etc/configure.py $CFG_CMD_LINE_ARGS
3131
if [ -f "$CONFIGURE_ROOT_DIR/bin/activate" ]; then
3232
source $CONFIGURE_ROOT_DIR/bin/activate
3333
fi

etc/conf/base.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@ pip
66
wincertstore
77

88
# used for templating
9-
jinja2==2.7.3
10-
MarkupSafe==0.23
9+
jinja2==2.9.6
10+
MarkupSafe==1.0.0
1111

12-
click==3.3
12+
click==6.7
1313

1414
# used by schematics
1515
six
1616

17-
pyyaml==3.11
18-
19-
20-
unicodecsv==0.9.4
17+
pyyaml==3.12
2118

2219
# license expression support
2320
license_expression

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ universal = 1
55
license_file = NOTICE
66

77
[aliases]
8-
release = clean --all sdist --formats=bztar,zip bdist_wheel register upload
8+
release = clean --all sdist --formats=bztar,zip bdist_wheel
99

10-
[pytest]
10+
[tool:pytest]
1111
norecursedirs =
1212
.git
1313
bin

setup.py

Lines changed: 30 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
2+
# -*- encoding: utf-8 -*-
33

44
from __future__ import absolute_import
55
from __future__ import print_function
@@ -10,6 +10,7 @@
1010
from os.path import dirname
1111
from os.path import join
1212
from os.path import splitext
13+
1314
from setuptools import find_packages
1415
from setuptools import setup
1516

@@ -22,16 +23,20 @@ def read(*names, **kwargs):
2223

2324

2425
setup(
25-
name='attributecode',
26-
version='3.0.0.dev4',
26+
name='aboutcode-toolkit',
27+
version='3.0.0.dev6',
2728
license='Apache-2.0',
28-
description=('Document the provenance (origin and license) of '
29-
'third-party software using small text files. '
30-
'Collect inventories, generate attribution documentation.'),
31-
long_description=('AttributeCode provides a simple way to document the'
29+
description=(
30+
'AboutCode-toolkit is a tool to document the provenance (origin and license) of '
31+
'third-party software using small text files. '
32+
'Collect inventories, generate attribution documentation.'
33+
),
34+
long_description=(
35+
'AttributeCode provides a simple way to document the'
3236
'provenance (i.e. origin and license) of software components that'
3337
'you use in your project. This documentation is stored in *.ABOUT'
34-
'files, side-by-side with the documented code.'),
38+
'files, side-by-side with the documented code.'
39+
),
3540
author='Chin-Yeung Li, Jillian Daguil, Thomas Druez, Philippe Ombredanne and others.',
3641
author_email='[email protected]',
3742
url='http://aboutcode.org',
@@ -46,59 +51,35 @@ def read(*names, **kwargs):
4651
'Programming Language :: Python',
4752
'Programming Language :: Python :: 2',
4853
'Programming Language :: Python :: 2.7',
54+
'Programming Language :: Python :: 3',
55+
'Programming Language :: Python :: 3.6',
56+
'Intended Audience :: Developers',
4957
'License :: OSI Approved :: Apache Software License',
5058
'Operating System :: OS Independent',
51-
'Intended Audience :: Developers',
5259
'Topic :: Software Development',
5360
'Topic :: Software Development :: Documentation',
5461
'Topic :: Software Development :: Quality Assurance',
5562
'Topic :: System :: Software Distribution',
5663
'Topic :: Utilities',
5764
],
5865
keywords=[
59-
'license', 'about', 'metadata', 'package', 'copyright',
66+
'license', 'about', 'metadata', 'package', 'copyright',
6067
'attribution', 'software', 'inventory',
6168
],
62-
data_files=[('about',
63-
[
64-
'about.ABOUT',
65-
'about.bat',
66-
'about',
67-
'configure.bat',
68-
'configure',
69-
'about.cfg',
70-
'README.rst',
71-
'apache-2.0.LICENSE',
72-
'NOTICE',
73-
'SPEC',
74-
'USAGE.rst',
75-
]),
76-
],
77-
78-
entry_points='''
79-
[console_scripts]
80-
about-code=attributecode.cmd:cli
81-
''',
8269
install_requires=[
83-
'jinja2 >= 2.7.3, < 2.8',
84-
'click >= 3.2, < 4',
85-
'unicodecsv >= 0.9.4, < 1.0',
70+
'jinja2 >= 2.9, < 3.0',
71+
'click >= 6.7, < 7.0',
72+
"backports.csv ; python_version<'3.6'",
8673
'pyyaml >= 3.11, < 3.13',
87-
'boolean.py',
88-
'license_expression',
89-
],
90-
74+
'boolean.py >= 3.5, < 4.0',
75+
'license_expression >= 0.94, < 1.0',
76+
],
9177
extras_require={
92-
'base': [
93-
'certifi',
94-
'setuptools',
95-
'wheel',
96-
'pip',
97-
'wincertstore',
98-
],
99-
'dev': [
100-
'pytest',
101-
'py',
102-
],
103-
}
78+
":python_version < '3.6'": ['backports.csv'],
79+
},
80+
entry_points={
81+
'console_scripts': [
82+
'about-code=attributecode.cmd:cli',
83+
]
84+
},
10485
)

src/attributecode/__init__.py

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,26 @@
1414
# limitations under the License.
1515
# ============================================================================
1616

17-
1817
from __future__ import absolute_import
1918
from __future__ import print_function
19+
from __future__ import unicode_literals
2020

2121
from collections import namedtuple
2222
import logging
2323

24-
__version__ = '3.0.0.dev5'
24+
try:
25+
basestring # Python 2
26+
except NameError:
27+
basestring = str # Python 3
28+
29+
30+
__version__ = '3.0.0.dev6'
31+
2532

2633
__about_spec_version__ = '2.0.0.dev2'
2734

2835
__copyright__ = """
29-
Copyright (c) 2013-2016 nexB Inc. All rights reserved. http://dejacode.org
36+
Copyright (c) 2013-2017 nexB Inc. All rights reserved. http://dejacode.org
3037
Licensed under the Apache License, Version 2.0 (the "License");
3138
you may not use this file except in compliance with the License.
3239
You may obtain a copy of the License at
@@ -38,15 +45,46 @@
3845
limitations under the License.
3946
"""
4047

41-
Error = namedtuple('Error', ['severity', 'message'])
4248

43-
def error_repr(self):
44-
sev = severities[self.severity]
45-
msg = self.message
46-
return 'Error(%(sev)s, %(msg)r)' % locals()
49+
class Error(namedtuple('Error', ['severity', 'message'])):
50+
"""
51+
An Error data with a severity and message.
52+
"""
53+
def __new__(self, severity, message):
54+
if message:
55+
if isinstance(message, basestring):
56+
message = clean_string(message)
57+
else:
58+
message = clean_string(repr(message))
59+
60+
return super(Error, self).__new__(
61+
Error, severity, message)
62+
63+
def __repr__(self, *args, **kwargs):
64+
sev = severities[self.severity]
65+
msg = clean_string(repr(self.message))
66+
return 'Error(%(sev)s, %(msg)s)' % locals()
4767

48-
Error.__repr__ = error_repr
4968

69+
def clean_string(s):
70+
"""
71+
Return a cleaned string for `s`, stripping eventual "u" prefixes
72+
from unicode representations.
73+
"""
74+
if not s:
75+
return s
76+
if s.startswith(('u"', "u'")):
77+
s = s.lstrip('u')
78+
s = s.replace('[u"', '["')
79+
s = s.replace("[u'", "['")
80+
s = s.replace("(u'", "('")
81+
s = s.replace("(u'", "('")
82+
s = s.replace("{u'", "{'")
83+
s = s.replace("{u'", "{'")
84+
s = s.replace(" u'", " '")
85+
s = s.replace(" u'", " '")
86+
s = s.replace("\\\\", "\\")
87+
return s
5088

5189
# modeled after the logging levels
5290
CRITICAL = 50

0 commit comments

Comments
 (0)