Skip to content

Commit 8556240

Browse files
authored
Merge pull request #3220 from nexB/get-valid-yaml
Get valid yaml output
2 parents 9939e13 + fa17213 commit 8556240

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2521
-943
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ License detection:
190190
This is now built-in with the --license-text option and --info
191191
and exposed with the "percentage_of_license_text" attribute.
192192

193+
- The license dump() has been modified to add an extra space at empty
194+
newlines for license files which also have multiple indentation levels
195+
as this was generating invalid YAML output files when ``--license-text``
196+
or ``--license-references`` was enabled.
197+
198+
See https://github.com/nexB/scancode-toolkit/issues/3219
193199

194200
v31.2.4 - 2023-01-09
195201
----------------------------------

docs/source/cli-reference/other-commands.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,11 @@ reindex the licenses without these licenses from the additional plugins.
100100

101101
Rebuild the license index including texts all languages (and not only
102102
English) and exit. This is an EXPERIMENTAL option.
103+
104+
105+
``--load-dump`` Option
106+
^^^^^^^^^^^^^^^^^^^^^^
107+
108+
Load all licenses and rules from their respective files and then dump them
109+
to their respective files. This is done to make small formatting changes across
110+
all licenses and rules, to be consistent across them.

docs/source/rst_snippets/scancode-reindex-licenses.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ Options
1818
--additional-directory DIR Include this directory with additional custom
1919
licenses and license rules in the license
2020
detection index.
21+
--load-dump Load all license and rules from their respective
22+
files and then dump them back to those same files.
2123
-h, --help Shows the options and explanations.

etc/scripts/licenses/buildrules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def cli(licenses_file):
213213
rl = models.BasicRule(text=rdata.text, **rdata.data)
214214
skinny_rules.append(rl)
215215

216-
models.validate_rules(skinny_rules, licenses_by_key, with_text=True)
216+
models.validate_rules(skinny_rules, licenses_by_key, with_text=True, thorough=True)
217217

218218
print()
219219
for rule in skinny_rules:

src/licensedcode/cache.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# global in-memory cache of the LicenseCache
3030
_LICENSE_CACHE = None
3131

32-
LICENSE_INDEX_LOCK_TIMEOUT = 60 * 4
32+
LICENSE_INDEX_LOCK_TIMEOUT = 60 * 6
3333
LICENSE_INDEX_DIR = 'license_index'
3434
LICENSE_INDEX_FILENAME = 'index_cache'
3535
LICENSE_LOCKFILE_NAME = 'scancode_license_index_lockfile'
@@ -134,8 +134,6 @@ def load_or_build(
134134
try:
135135
# acquire lock and wait until timeout to get a lock or die
136136
with lockfile.FileLock(lock_file).locked(timeout=timeout):
137-
# Here, the cache is either stale or non-existing: we need to
138-
# rebuild all cached data (e.g. mostly the index) and cache it
139137

140138
additional_directories = []
141139
if only_builtin:
@@ -156,6 +154,8 @@ def load_or_build(
156154
additional_directories=additional_license_dirs,
157155
scancode_license_dir=licenses_data_dir
158156
)
157+
# Here, the cache is either stale or non-existing: we need to
158+
# rebuild all cached data (e.g. mostly the index) and cache it
159159
licenses_db = load_licenses_from_multiple_dirs(
160160
additional_license_data_dirs=additional_license_dirs,
161161
builtin_license_data_dir=licenses_data_dir,

0 commit comments

Comments
 (0)