Skip to content

Commit ea8953b

Browse files
Merge pull request #3662 from nexB/misc-updates
Add Misc updates
2 parents 66d7166 + 6df90d5 commit ea8953b

File tree

15 files changed

+98
-89
lines changed

15 files changed

+98
-89
lines changed

src/cluecode/copyrights.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,7 +2517,8 @@ def build_detection_from_node(
25172517
COMPANY: {<COMPANY> <MAINT>} #19603
25182518
25192519
2520-
#######################################
2520+
################################# #COPYRIGHT: {<COPY> <COPY> <MIT>} #1802
2521+
######
25212522
# VARIOUS FORMS OF COPYRIGHT
25222523
#######################################
25232524
@@ -2572,6 +2573,8 @@ def build_detection_from_node(
25722573
25732574
COPYRIGHT: {<COPY> <COPY> <COMP>+} #1690
25742575
2576+
COPYRIGHT: {<COPY> <COPY> <MIT>} #1802
2577+
25752578
COPYRIGHT: {<COPY> <COPY> <NN>+ <COMPANY|NAME|NAME-EMAIL>+} #1710
25762579
25772580
COPYRIGHT: {<COPY> <COPY> <NN> <NNP> <NN> <COMPANY>} #1711
@@ -4125,8 +4128,10 @@ def prepare_text_line(line, dedeb=True, to_ascii=True):
41254128

41264129
# normalize (possibly repeated) quotes to unique single quote '
41274130
# backticks ` and "
4128-
.replace('`', u"'")
4129-
.replace('"', u"'")
4131+
.replace('`', "'")
4132+
.replace('"', "'")
4133+
# see https://github.com/nexB/scancode-toolkit/issues/3667
4134+
.replace('§', " ")
41304135
)
41314136

41324137
if TRACE_TOK:

src/packagedcode/gemfile_lock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@ def get_option(s):
340340
'%(NAME_VERSION)s'
341341
'$' % locals()).match
342342

343-
PLATS = re.compile('^ (?P<platform>.*)$').match
344-
BUNDLED_WITH = re.compile('^\s+(?P<version>(?:\d+.)+\d+)\s*$').match
343+
PLATS = re.compile(r'^ (?P<platform>.*)$').match
344+
BUNDLED_WITH = re.compile(r'^\s+(?P<version>(?:\d+.)+\d+)\s*$').match
345345

346346

347347
class GemfileLockParser:

src/packagedcode/recognize.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from packagedcode import ALL_DATAFILE_HANDLERS
1717
from packagedcode import models
1818

19-
TRACE = False or os.environ.get('SCANCODE_DEBUG_PACKAGE_API', False)
19+
TRACE = os.environ.get('SCANCODE_DEBUG_PACKAGE_API', False)
2020

2121

2222
def logger_debug(*args):
@@ -62,7 +62,6 @@ def recognize_package_data(
6262
datafile_handlers = APPLICATION_PACKAGE_DATAFILE_HANDLERS
6363
elif system:
6464
datafile_handlers = SYSTEM_PACKAGE_DATAFILE_HANDLERS
65-
6665
return list(_parse(location, datafile_handlers=datafile_handlers))
6766

6867

@@ -78,6 +77,9 @@ def _parse(
7877
"""
7978

8079
for handler in datafile_handlers:
80+
if TRACE:
81+
logger_debug(f'_parse:.is_datafile: {handler}')
82+
8183
if not handler.is_datafile(location):
8284
continue
8385

src/packagedcode/rpm.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ class RpmInstalledNdbDatabaseHandler(BaseRpmInstalledDatabaseHandler):
233233
# TODO: add dependencies!!!
234234
class RpmInstalledSqliteDatabaseHandler(BaseRpmInstalledDatabaseHandler):
235235
# used by newer RHEL/CentOS/Fedora/CoreOS
236+
# Filetype: SQLite 3.x database, ...
237+
# Mimetype: application/vnd.sqlite3
238+
236239
datasource_id = 'rpm_installed_database_sqlite'
237240
path_patterns = ('*rpm/rpmdb.sqlite',)
238241
default_package_type = 'rpm'

src/summarycode/generated.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,17 @@ def generated_scanner(location, **kwargs):
176176
# protoc
177177
'generated by the protocol buffer compiler',
178178
'generated by the protocol buffer compiler. do not edit!',
179+
'generated by the protocol buffer compiler. do not edit!',
180+
'code generated by protoc-gen-go. do not edit.',
181+
'code generated by generate-types. do not edit.',
182+
'code generated by generate-protos. do not edit.',
183+
'do not edit -- your changes will be discarded when the file is', # next line: * regenerated.
184+
'do not edit -- generated code',
185+
'generated code -- do not edit!',
186+
'autogenerated by method_dump.sh. do not edit by hand.',
187+
'this file is generated from the .proto files for the well-known', # next line: types. Do not edit!
188+
'this file was generated by upbc (the upb compiler) from the input',
189+
'do not edit -- your changes will be discarded when the file is', # next line: regenerated
179190

180191
# autotools
181192
'makefile.in generated by automake',
@@ -191,6 +202,7 @@ def generated_scanner(location, **kwargs):
191202
'generated by:javacc: do not edit this line',
192203
'generated by:jjtree: do not edit this line',
193204
'generated code (do not edit this line)',
205+
194206
))
195207

196208

src/textcode/strings.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,33 +180,33 @@ def is_shared_object(s):
180180
return so(s)
181181

182182

183+
# TODO: implement me
184+
_posix = re.compile('^/[\\w_\\-].*$', re.IGNORECASE).match
183185
def is_posix_path(s):
184186
"""
185187
Return True if s looks like a posix path.
186188
Example: /usr/lib/librt.so.1 or /usr/lib
187189
"""
188-
# TODO: implement me
189-
posix = re.compile('^/[\\w_\\-].*$', re.IGNORECASE).match
190-
posix(s)
191-
return False
190+
return _posix(s)
192191

193192

193+
# TODO: implement me
194+
_relative = re.compile('^(?:([^/]|\\.\\.)[\\w_\\-]+/.*$)', re.IGNORECASE).match
194195
def is_relative_path(s):
195196
"""
196197
Return True if s looks like a relative posix path.
197198
Example: usr/lib/librt.so.1 or ../usr/lib
198199
"""
199-
relative = re.compile('^(?:([^/]|\\.\\.)[\\w_\\-]+/.*$)', re.IGNORECASE).match
200-
return relative(s)
200+
return bool(_relative(s))
201201

202202

203+
_winpath = re.compile('^[\\w_\\-]+\\.so\\.[0-9]+\\.*.[0-9]*$', re.IGNORECASE).match
203204
def is_win_path(s):
204205
"""
205206
Return True if s looks like a win path.
206207
Example: c:\\usr\\lib\\librt.so.1.
207208
"""
208-
winpath = re.compile('^[\\w_\\-]+\\.so\\.[0-9]+\\.*.[0-9]*$', re.IGNORECASE).match
209-
return winpath(s)
209+
return _winpath(s)
210210

211211

212212
def is_c_source(s):

src/textcode/strings2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import re
2424

2525
ASCII_BYTE = (
26-
" !\"#\$%&\'\(\)\*\+,-\./0123456789:;<=>\?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"
27-
"\[\]\^_`abcdefghijklmnopqrstuvwxyz\{\|\}\\\~\t"
26+
r" !\"#\$%&\'\(\)\*\+,-\./0123456789:;<=>\?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"
27+
r"\[\]\^_`abcdefghijklmnopqrstuvwxyz\{\|\}\\\~\t"
2828
)
2929

3030

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright (C) 2016§ The Android Open Source Project
4+
-->
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
what:
2+
- copyrights
3+
copyrights:
4+
- Copyright (c) 2016 The Android Open Source Project

tests/packagedcode/test_gemfile_lock.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def test_Gem_as_nv_tree(self):
274274
}
275275
}
276276
}
277-
self.assertEqual(expected, a.as_nv_tree())
277+
assert a.as_nv_tree() == expected
278278

279279
def test_Gem_flatten(self):
280280
Gem = gemfile_lock.Gem
@@ -320,7 +320,6 @@ def test_Gem_as_nv_tree_with_no_deps(self):
320320
results = a.as_nv_tree()
321321
assert results == expected
322322

323-
324323
def test_Gem_to_dict(self):
325324
Gem = gemfile_lock.Gem
326325
a = Gem('a', '1')

0 commit comments

Comments
 (0)