Merging upstream version 2.2.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
13a62a0f54
commit
e5b299766a
5 changed files with 16 additions and 12 deletions
|
@ -11,17 +11,17 @@ repos:
|
||||||
- id: requirements-txt-fixer
|
- id: requirements-txt-fixer
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- repo: https://github.com/asottile/setup-cfg-fmt
|
- repo: https://github.com/asottile/setup-cfg-fmt
|
||||||
rev: v1.16.0
|
rev: v1.17.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: setup-cfg-fmt
|
- id: setup-cfg-fmt
|
||||||
- repo: https://gitlab.com/pycqa/flake8
|
- repo: https://gitlab.com/pycqa/flake8
|
||||||
rev: 3.8.4
|
rev: 3.9.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
exclude: ^identify/vendor/licenses\.py$
|
exclude: ^identify/vendor/licenses\.py$
|
||||||
additional_dependencies: [flake8-typing-imports==1.10.1]
|
additional_dependencies: [flake8-typing-imports==1.10.1]
|
||||||
- repo: https://github.com/pre-commit/mirrors-autopep8
|
- repo: https://github.com/pre-commit/mirrors-autopep8
|
||||||
rev: v1.5.4
|
rev: v1.5.5
|
||||||
hooks:
|
hooks:
|
||||||
- id: autopep8
|
- id: autopep8
|
||||||
- repo: https://github.com/asottile/reorder_python_imports
|
- repo: https://github.com/asottile/reorder_python_imports
|
||||||
|
|
|
@ -226,6 +226,7 @@ NAMES = {
|
||||||
'.bash_aliases': EXTENSIONS['bash'],
|
'.bash_aliases': EXTENSIONS['bash'],
|
||||||
'.bash_profile': EXTENSIONS['bash'],
|
'.bash_profile': EXTENSIONS['bash'],
|
||||||
'.bashrc': EXTENSIONS['bash'],
|
'.bashrc': EXTENSIONS['bash'],
|
||||||
|
'.bazelrc': {'text', 'bazelrc'},
|
||||||
'.bowerrc': EXTENSIONS['json'] | {'bowerrc'},
|
'.bowerrc': EXTENSIONS['json'] | {'bowerrc'},
|
||||||
'.browserslistrc': {'text', 'browserslistrc'},
|
'.browserslistrc': {'text', 'browserslistrc'},
|
||||||
'.clang-format': EXTENSIONS['yaml'],
|
'.clang-format': EXTENSIONS['yaml'],
|
||||||
|
@ -261,6 +262,7 @@ NAMES = {
|
||||||
'COPYING': EXTENSIONS['txt'],
|
'COPYING': EXTENSIONS['txt'],
|
||||||
'Dockerfile': {'text', 'dockerfile'},
|
'Dockerfile': {'text', 'dockerfile'},
|
||||||
'Gemfile': EXTENSIONS['rb'],
|
'Gemfile': EXTENSIONS['rb'],
|
||||||
|
'Gemfile.lock': {'text'},
|
||||||
'Jenkinsfile': {'text', 'groovy'},
|
'Jenkinsfile': {'text', 'groovy'},
|
||||||
'LICENSE': EXTENSIONS['txt'],
|
'LICENSE': EXTENSIONS['txt'],
|
||||||
'MAINTAINERS': EXTENSIONS['txt'],
|
'MAINTAINERS': EXTENSIONS['txt'],
|
||||||
|
|
|
@ -240,7 +240,7 @@ def license_id(filename: str) -> Optional[str]:
|
||||||
3. check exact text match with existing licenses
|
3. check exact text match with existing licenses
|
||||||
4. failing that use edit distance
|
4. failing that use edit distance
|
||||||
"""
|
"""
|
||||||
import editdistance # `pip install identify[license]`
|
import editdistance_s # `pip install identify[license]`
|
||||||
|
|
||||||
with open(filename, encoding='UTF-8') as f:
|
with open(filename, encoding='UTF-8') as f:
|
||||||
contents = f.read()
|
contents = f.read()
|
||||||
|
@ -260,7 +260,7 @@ def license_id(filename: str) -> Optional[str]:
|
||||||
if norm and abs(len(norm) - len(norm_license)) / len(norm) > .05:
|
if norm and abs(len(norm) - len(norm_license)) / len(norm) > .05:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
edit_dist = editdistance.eval(norm, norm_license)
|
edit_dist = editdistance_s.distance(norm, norm_license)
|
||||||
if edit_dist < min_edit_dist:
|
if edit_dist < min_edit_dist:
|
||||||
min_edit_dist = edit_dist
|
min_edit_dist = edit_dist
|
||||||
min_edit_dist_spdx = spdx
|
min_edit_dist_spdx = spdx
|
||||||
|
|
14
setup.cfg
14
setup.cfg
|
@ -1,6 +1,6 @@
|
||||||
[metadata]
|
[metadata]
|
||||||
name = identify
|
name = identify
|
||||||
version = 2.1.2
|
version = 2.2.0
|
||||||
description = File identification library for Python
|
description = File identification library for Python
|
||||||
long_description = file: README.md
|
long_description = file: README.md
|
||||||
long_description_content_type = text/markdown
|
long_description_content_type = text/markdown
|
||||||
|
@ -24,18 +24,18 @@ classifiers =
|
||||||
packages = find:
|
packages = find:
|
||||||
python_requires = >=3.6.1
|
python_requires = >=3.6.1
|
||||||
|
|
||||||
|
[options.packages.find]
|
||||||
|
exclude =
|
||||||
|
tests*
|
||||||
|
testing*
|
||||||
|
|
||||||
[options.entry_points]
|
[options.entry_points]
|
||||||
console_scripts =
|
console_scripts =
|
||||||
identify-cli=identify.cli:main
|
identify-cli=identify.cli:main
|
||||||
|
|
||||||
[options.extras_require]
|
[options.extras_require]
|
||||||
license =
|
license =
|
||||||
editdistance
|
editdistance-s
|
||||||
|
|
||||||
[options.packages.find]
|
|
||||||
exclude =
|
|
||||||
tests*
|
|
||||||
testing*
|
|
||||||
|
|
||||||
[bdist_wheel]
|
[bdist_wheel]
|
||||||
universal = True
|
universal = True
|
||||||
|
|
|
@ -158,6 +158,8 @@ def test_tags_from_path_plist_text(tmpdir):
|
||||||
('Pipfile.lock', {'text', 'json'}),
|
('Pipfile.lock', {'text', 'json'}),
|
||||||
('mod/test.py', {'text', 'python'}),
|
('mod/test.py', {'text', 'python'}),
|
||||||
('mod/Dockerfile', {'text', 'dockerfile'}),
|
('mod/Dockerfile', {'text', 'dockerfile'}),
|
||||||
|
('Gemfile', {'text', 'ruby'}),
|
||||||
|
('Gemfile.lock', {'text'}),
|
||||||
|
|
||||||
# does not set binary / text
|
# does not set binary / text
|
||||||
('f.plist', {'plist'}),
|
('f.plist', {'plist'}),
|
||||||
|
|
Loading…
Add table
Reference in a new issue