File tree Expand file tree Collapse file tree 8 files changed +54
-39
lines changed Expand file tree Collapse file tree 8 files changed +54
-39
lines changed Original file line number Diff line number Diff line change @@ -2517,7 +2517,8 @@ def build_detection_from_node(
2517
2517
COMPANY: {<COMPANY> <MAINT>} #19603
2518
2518
2519
2519
2520
- #######################################
2520
+ ################################# #COPYRIGHT: {<COPY> <COPY> <MIT>} #1802
2521
+ ######
2521
2522
# VARIOUS FORMS OF COPYRIGHT
2522
2523
#######################################
2523
2524
@@ -2572,6 +2573,8 @@ def build_detection_from_node(
2572
2573
2573
2574
COPYRIGHT: {<COPY> <COPY> <COMP>+} #1690
2574
2575
2576
+ COPYRIGHT: {<COPY> <COPY> <MIT>} #1802
2577
+
2575
2578
COPYRIGHT: {<COPY> <COPY> <NN>+ <COMPANY|NAME|NAME-EMAIL>+} #1710
2576
2579
2577
2580
COPYRIGHT: {<COPY> <COPY> <NN> <NNP> <NN> <COMPANY>} #1711
Original file line number Diff line number Diff line change 16
16
from packagedcode import ALL_DATAFILE_HANDLERS
17
17
from packagedcode import models
18
18
19
- TRACE = False or os .environ .get ('SCANCODE_DEBUG_PACKAGE_API' , False )
19
+ TRACE = os .environ .get ('SCANCODE_DEBUG_PACKAGE_API' , False )
20
20
21
21
22
22
def logger_debug (* args ):
@@ -62,7 +62,6 @@ def recognize_package_data(
62
62
datafile_handlers = APPLICATION_PACKAGE_DATAFILE_HANDLERS
63
63
elif system :
64
64
datafile_handlers = SYSTEM_PACKAGE_DATAFILE_HANDLERS
65
-
66
65
return list (_parse (location , datafile_handlers = datafile_handlers ))
67
66
68
67
@@ -78,6 +77,9 @@ def _parse(
78
77
"""
79
78
80
79
for handler in datafile_handlers :
80
+ if TRACE :
81
+ logger_debug (f'_parse:.is_datafile: { handler } ' )
82
+
81
83
if not handler .is_datafile (location ):
82
84
continue
83
85
Original file line number Diff line number Diff line change @@ -233,6 +233,9 @@ class RpmInstalledNdbDatabaseHandler(BaseRpmInstalledDatabaseHandler):
233
233
# TODO: add dependencies!!!
234
234
class RpmInstalledSqliteDatabaseHandler (BaseRpmInstalledDatabaseHandler ):
235
235
# used by newer RHEL/CentOS/Fedora/CoreOS
236
+ # Filetype: SQLite 3.x database, ...
237
+ # Mimetype: application/vnd.sqlite3
238
+
236
239
datasource_id = 'rpm_installed_database_sqlite'
237
240
path_patterns = ('*rpm/rpmdb.sqlite' ,)
238
241
default_package_type = 'rpm'
Original file line number Diff line number Diff line change @@ -180,33 +180,33 @@ def is_shared_object(s):
180
180
return so (s )
181
181
182
182
183
+ # TODO: implement me
184
+ _posix = re .compile ('^/[\\ w_\\ -].*$' , re .IGNORECASE ).match
183
185
def is_posix_path (s ):
184
186
"""
185
187
Return True if s looks like a posix path.
186
188
Example: /usr/lib/librt.so.1 or /usr/lib
187
189
"""
188
- # TODO: implement me
189
- posix = re .compile ('^/[\\ w_\\ -].*$' , re .IGNORECASE ).match
190
- posix (s )
191
- return False
190
+ return _posix (s )
192
191
193
192
193
+ # TODO: implement me
194
+ _relative = re .compile ('^(?:([^/]|\\ .\\ .)[\\ w_\\ -]+/.*$)' , re .IGNORECASE ).match
194
195
def is_relative_path (s ):
195
196
"""
196
197
Return True if s looks like a relative posix path.
197
198
Example: usr/lib/librt.so.1 or ../usr/lib
198
199
"""
199
- relative = re .compile ('^(?:([^/]|\\ .\\ .)[\\ w_\\ -]+/.*$)' , re .IGNORECASE ).match
200
- return relative (s )
200
+ return bool (_relative (s ))
201
201
202
202
203
+ _winpath = re .compile ('^[\\ w_\\ -]+\\ .so\\ .[0-9]+\\ .*.[0-9]*$' , re .IGNORECASE ).match
203
204
def is_win_path (s ):
204
205
"""
205
206
Return True if s looks like a win path.
206
207
Example: c:\\ usr\\ lib\\ librt.so.1.
207
208
"""
208
- winpath = re .compile ('^[\\ w_\\ -]+\\ .so\\ .[0-9]+\\ .*.[0-9]*$' , re .IGNORECASE ).match
209
- return winpath (s )
209
+ return _winpath (s )
210
210
211
211
212
212
def is_c_source (s ):
Original file line number Diff line number Diff line change @@ -274,7 +274,7 @@ def test_get_top_level_resources(self):
274
274
pom_resource = codebase .get_resource (
275
275
'activiti-image-generator-7-201802-EA-sources.jar-extract/META-INF/maven/org.activiti/activiti-image-generator/pom.xml'
276
276
)
277
- assert pom_resource is True
277
+ assert pom_resource
278
278
top_level_resources_paths = [
279
279
r .path for r in maven .MavenPomXmlHandler .get_top_level_resources (pom_resource , codebase )
280
280
]
Original file line number Diff line number Diff line change @@ -417,23 +417,23 @@ def test_parse_dependency_file_with_invalid_does_not_fail(self):
417
417
expected_loc = self .get_test_loc ('pypi/requirements_txt/invalid_spec/output.expected.json' )
418
418
self .check_packages_data (package , expected_loc , regen = REGEN_TEST_FIXTURES )
419
419
420
- @pytest .mark .parametrize (
421
- 'filename' ,
422
- [
423
- 'dev-requirements.txt' ,
424
- 'reqs.txt' ,
425
- 'requirements/base.txt' ,
426
- 'requirements-dev.txt' ,
427
- 'requirements.in' ,
428
- 'requirements.pip' ,
429
- 'requirements.txt' ,
430
- 'requirement.txt' ,
431
- 'requires.txt' ,
432
- 'some-requirements-dev.txt' ,
433
- ]
434
- )
435
- def test_PipRequirementsFileHandler_is_datafile (self , filename ):
436
- assert pypi .PipRequirementsFileHandler .is_datafile (filename , _bare_filename = True )
420
+ @pytest .mark .parametrize (
421
+ 'filename' ,
422
+ [
423
+ 'dev-requirements.txt' ,
424
+ 'reqs.txt' ,
425
+ 'requirements/base.txt' ,
426
+ 'requirements-dev.txt' ,
427
+ 'requirements.in' ,
428
+ 'requirements.pip' ,
429
+ 'requirements.txt' ,
430
+ 'requirement.txt' ,
431
+ 'requires.txt' ,
432
+ 'some-requirements-dev.txt' ,
433
+ ]
434
+ )
435
+ def test_PipRequirementsFileHandler_is_datafile (filename ):
436
+ assert pypi .PipRequirementsFileHandler .is_datafile (location = filename , _bare_filename = True )
437
437
438
438
439
439
class TestPyPiPipfile (PackageTester ):
Original file line number Diff line number Diff line change @@ -258,16 +258,15 @@ def test_get_primary_language(self):
258
258
assert result_1 == expected_1
259
259
260
260
def test_get_holders_from_copyright (self ):
261
- test_copyright = 'Copyright (c) 2017, The University of Chicago. All rights reserved.'
262
- expected_1 = ['The University of Chicago' ]
263
- result_1 = get_holders_from_copyright (test_copyright )
264
- assert result_1 == expected_1
261
+ test_copyright_string = 'Copyright (c) 2017, The University of Chicago. All rights reserved.'
262
+ result = list (get_holders_from_copyright (test_copyright_string ))
263
+ assert result == ['The University of Chicago' ]
265
264
266
- test_copyrights = [
265
+ test_copyright_lines = [
267
266
'Copyright (c) 2017, The University of Chicago. All rights reserved.' ,
268
267
'Copyright (c) MIT' ,
269
268
'Copyright (c) Apache Software Foundation' ,
270
269
]
271
- expected_2 = [ 'The University of Chicago' , 'MIT' , 'Apache Software Foundation' ]
272
- result_2 = get_holders_from_copyright (test_copyrights )
273
- assert result_2 == expected_2
270
+
271
+ result = list ( get_holders_from_copyright (test_copyright_lines ) )
272
+ assert result == [ 'The University of Chicago' , 'MIT' , 'Apache Software Foundation' ]
Original file line number Diff line number Diff line change 11
11
import json
12
12
import os
13
13
14
+ import pytest
14
15
from commoncode .testcase import FileBasedTesting
15
16
16
17
from scancode_config import REGEN_TEST_FIXTURES
17
18
from textcode import strings
18
19
19
20
21
+
20
22
class TestStrings (FileBasedTesting ):
21
23
test_data_dir = os .path .join (os .path .dirname (__file__ ), 'data' )
22
24
@@ -159,11 +161,17 @@ def test_strings_in_all_bin(self):
159
161
expected_file = os .path .join (expec_dir , tf + '.strings' )
160
162
self .check_file_strings (test_file , expected_file )
161
163
162
- def test_is_relative_path (self ):
164
+ def test_is_relative_path_win (self ):
163
165
# Win Path
164
166
path = "c:\\ usr\\ lib\\ librt.so.1."
165
- assert strings .is_relative_path (path ) is False
167
+ assert not strings .is_relative_path (path )
168
+
169
+ @pytest .mark .xfail (reason = "is_relative_path is not implemented on Windows" )
170
+ def test_is_relative_path_win2 (self ):
171
+ path = "usr\\ lib\\ librt.so.1."
172
+ assert strings .is_relative_path (path ) is True
166
173
174
+ def test_is_relative_path_posix (self ):
167
175
# Relative Posix Path
168
176
path = "usr/lib/librt.so.1"
169
177
assert strings .is_relative_path (path ) is True
You can’t perform that action at this time.
0 commit comments