Skip to content

Commit

Permalink
Use unicode literals. Format code. #295
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
  • Loading branch information
pombredanne committed Jun 28, 2017
1 parent 3a26142 commit bb915a1
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions src/licensedcode/legal.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
# ScanCode is a free software code scanning tool from nexB Inc. and others.
# Visit https://github.com/nexB/scancode-toolkit/ for support and download.

from __future__ import print_function, absolute_import
from __future__ import print_function
from __future__ import absolute_import
from __future__ import unicode_literals

from commoncode import fileutils

Expand All @@ -32,29 +34,33 @@
"""


special_names = ('COPYING', 'COPYRIGHT', 'NOTICE', 'LICENSE', 'LICENCE',
'LEGAL', 'EULA', 'AGREEMENT', 'ABOUT', 'COPYLEFT', 'LICENSING')
special_names = (
'COPYING', 'COPYRIGHT', 'NOTICE', 'LICENSE', 'LICENCE',
'LEGAL', 'EULA', 'AGREEMENT', 'ABOUT', 'COPYLEFT', 'LICENSING')


special_names_lower = tuple(x.lower() for x in special_names)


def is_special_legal_file(location):
file_base_name = fileutils.file_base_name(location).lower()
file_extension = fileutils.file_extension(location).lower()

if (any(special_name == file_base_name
or special_name == file_extension
for special_name in special_names_lower)
or any(special_name in file_base_name
or special_name in file_extension
for special_name in special_names)):
return 'yes'

elif any(special_name in file_base_name
or special_name in file_extension
for special_name in special_names_lower):
return 'maybe'
else:
# return False for now?
pass
"""
Return an indication that a file may be a "special" legal-like file.
"""
file_base_name = fileutils.file_base_name(location).lower()
file_extension = fileutils.file_extension(location).lower()

if (any(special_name == file_base_name
or special_name == file_extension
for special_name in special_names_lower)
or any(special_name in file_base_name
or special_name in file_extension
for special_name in special_names)):
return 'yes'

elif any(special_name in file_base_name
or special_name in file_extension
for special_name in special_names_lower):
return 'maybe'
else:
# return False for now?
pass

0 comments on commit bb915a1

Please sign in to comment.