Skip to content

Commit 54fb102

Browse files
Refactor external licenses code
Refactor according to the feedback. Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
1 parent 095c8ed commit 54fb102

File tree

7 files changed

+13
-9
lines changed

7 files changed

+13
-9
lines changed

azure-pipelines.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ jobs:
3232
--ignore=tests/licensedcode/test_detection_datadriven1.py \
3333
--ignore=tests/licensedcode/test_detection_datadriven2.py \
3434
--ignore=tests/licensedcode/test_detection_datadriven3.py \
35-
--ignore=tests/licensedcode/test_detection_datadriven4.py
35+
--ignore=tests/licensedcode/test_detection_datadriven4.py \
36+
--ignore=tests/licensedcode/test_additional_license.py \
37+
tests/licensedcode
3638
3739
license_datadriven1_2: |
3840
venv/bin/pytest -n 3 -vvs --test-suite=all \

src/licensedcode/cache.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ def load_or_build(
7272
On the side, we load cached or build license db, SPDX symbols and other
7373
license-related data structures.
7474
75-
- If the cache exists, it is returned unless corrupted, ``force`` is True, or if we pass in additional
76-
directories containing licenses that are not present in the existing cache.
77-
- If the cache does not exist, a new index is built and cached.
75+
- If the cache exists, it is returned unless corrupted.
76+
- If ``force`` is True, or if the cache does not exist a new index is built
77+
and cached.
7878
- If ``index_all_languages`` is True, include texts in all languages when
7979
building the license index. Otherwise, only include the English license
8080
texts and rules (the default)

src/licensedcode/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ def write(location, byte_string):
444444
if text:
445445
write(self.text_file(licenses_data_dir=licenses_data_dir), text.encode('utf-8'))
446446

447+
return self
448+
447449
def load(self, data_file, text_file):
448450
"""
449451
Populate license data from a YAML file stored in ``data_file`` and ``text_file``.

src/licensedcode/reindex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
'--only-builtin',
2525
is_flag=True,
2626
help='Rebuild the license index excluding any additional '
27-
'license directory or additional license plugins which'
27+
'license directory or additional license plugins which '
2828
'were added previously, i.e. with only builtin scancode '
2929
'license and rules.',
3030
conflicting_options=['additional_directory'],

tests/licensedcode/data/plugin_license/license_url.expected.json renamed to tests/licensedcode/data/plugin_license/license_url/license_url.expected.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"files": [
33
{
4-
"path": "license_url",
4+
"path": "scan",
55
"type": "directory",
66
"licenses": [],
77
"license_expressions": [],
88
"percentage_of_license_text": 0,
99
"scan_errors": []
1010
},
1111
{
12-
"path": "license_url/apache-1.0.txt",
12+
"path": "scan/apache-1.0.txt",
1313
"type": "file",
1414
"licenses": [
1515
{

tests/licensedcode/test_plugin_license.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def test_reindex_licenses_works():
245245

246246
@pytest.mark.scanslow
247247
def test_scan_license_with_url_template():
248-
test_dir = test_env.get_test_loc('plugin_license/license_url', copy=True)
248+
test_dir = test_env.get_test_loc('plugin_license/license_url/scan/', copy=True)
249249
result_file = test_env.get_temp_file('json')
250250
args = [
251251
'--license',
@@ -254,7 +254,7 @@ def test_scan_license_with_url_template():
254254
'--json-pp', result_file,
255255
test_dir,
256256
]
257-
test_loc = test_env.get_test_loc('plugin_license/license_url.expected.json')
257+
test_loc = test_env.get_test_loc('plugin_license/license_url/license_url.expected.json')
258258
run_scan_click(args)
259259
check_json_scan(test_loc, result_file, regen=REGEN_TEST_FIXTURES)
260260

0 commit comments

Comments
 (0)