check_license_information
Overview
The check_license_information module validates and normalizes license links for each article. It compares license URLs extracted from CrossRef metadata and the full-text XML against a central variants file (explained below), and either writes a
license.json(success) orlicense-error.json+ stop folder (failure)
The module has two main types of users:
- Maintainers maintain three sources of configuration (a variants file, a publisher override file, and per-journal
license-periodsin the flow config). They also handle stop folders when articles need manual review. - Developers work with two primary Python files:
flow.pyandtasks.py.
The rest of this page is split into a Configuration workflow section (for maintainers) and a Code reference section (for developers).
Configuration workflow (Maintainer)
Configuration files
The module relies on three operator-managed sources of configuration. They can be found on the NAS or inside the per-flow JSON config, and are maintained manually as new license variants, new publishers, and new edge cases appear.
| File | Location | Purpose |
|---|---|---|
license-links-normalized.json |
W:\wdm-test\module_config_files\check_license_information\ |
Maps every known CC license variant URL to its canonical (normalized) form. |
publishers_with_single_license_link_source.txt |
W:\wdm-test\module_config_files\check_license_information\ |
Publisher source-names (one per line) for which license info from a single source is treated as authoritative. |
license-periods |
Inside the per-publisher flow config | Per-journal mapping of date ranges to license URLs, used when neither CrossRef nor XML contain license links. |
Routine workflow for stop folders
This is the operator workflow whenever an article ends up in a stop folder.
- Open the error CSV log.
- Each stop-processing article gets an entry in the error CSV. Each entry contains the article path and the full path to the
license-error.jsonfile inside the stop folder. - Open the
license-error.jsonfile. - It lists the deduplicated license links found in CrossRef metadata and in the full-text XML separately. From this you decide which of cases b through g the article fell into. (Case a is the success case where both CrossRef metadata and the full-text XML contain license links, and after normalization all links from both sources are identical. )
Then act based on the case:
- Case b (links present in both sources but differ): Inspect the two link lists in
license-error.json. - If the only difference is formatting (http vs https, trailing slash, etc.) and both links refer to the same license: extend
license-links-normalized.json(see below). - If the links refer to genuinely different licenses (e.g. CC-BY vs CC-BY-SA): check the publisher's website to determine which is correct. The correction is a manual decision.
- Cases c and e (one source has consistent links, the other has none): If the publisher consistently produces license info in only one source: add the publisher to
publishers_with_single_license_link_source.txt(see below). Articles will pass on the next run. - Cases d and f (one source missing, the other inconsistent): The inconsistent source must be inspected on the publisher's site to decide which link is correct. Manual decision.
- Case g (no license links anywhere): If you can determine the license from the journal's website manually, extend the journal's
license-periodsarray in the flow config (see below). Articles will pass on the next run. - After making the configuration change, delete the
stop-processing_check_license_information_<date>folder. The previous module folder (preserved as a subfolder inside the stop folder) will need to be restored before re-running.
Maintaining license-links-normalized.json
This is the most frequently modified file. Expect to extend it as new license variants surface.
- File structure:
{
"licenses": [
{
"normalized_url": "https://creativecommons.org/licenses/by/4.0/",
"variants": [
"https://creativecommons.org/licenses/by/4.0/",
"https://creativecommons.org/licenses/by/4.0",
"http://creativecommons.org/licenses/by/4.0/",
"http://creativecommons.org/licenses/by/4.0"
]
}
]
}
-
When to extend it: Whenever a case-b stop folder shows two URLs that are clearly the same license but formatted differently, or when a known license type appears that isn't represented in the file at all.
-
How to extend it:
- If the missing variants belong to a license already present (a known
normalized_url): add the new variant strings to that entry'svariantslist. -
If the license itself is new (e.g. CC BY-NC-ND not yet present): add a new object to the
licensesarray with anormalized_urlfield and avariantslist. Use thehttps+ trailing-slash form as thenormalized_url. -
Note: Variants are matched after stripping whitespace and lower-casing, so the file does not need both upper- and lower-case forms. It does, however, need both
http/httpsand both slash/no-slash forms because those are textually different.
Maintaining publishers_with_single_license_link_source.txt
-
File structure: One publisher source-name per line. The source-name is the value of the
source-namefield in the flow config (e.g.MDPI,Springer Nature). -
When to add a publisher: Per the WDM Sitzung policy, when a publisher consistently provides license info in only one source (either CrossRef or XML, but not both):
- Contact the publisher once to ask whether they will add the missing license information.
-
If the publisher does not respond or refuses, add their source-name to this file. From that point on, the module will accept their single-source license info as authoritative (provided it is internally consistent).
-
Effect on the module: With the publisher in this list, cases c and e are treated as success instead of stop. The single license link is taken from whichever source provided it, and
license.jsonrecords that source as the origin.
Configuring license-periods in the flow config
-
When to use it: When neither CrossRef nor the full-text XML contain any license link for a journal's articles, but you have determined the journal's license history manually (from the publisher's website).
-
Where to add it: Inside the relevant flow config file, within the journal's object.
-
Structure:
{
"issn-e": "2076-0825",
"journal-name": "Actuators",
"license-periods": [
{
"valid-from": "2010-01-01",
"valid-to": "2012-05-31",
"normalized-url": "https://creativecommons.org/licenses/by/4.0/"
},
{
"valid-from": "2012-06-01",
"valid-to": "2025-12-31",
"normalized-url": "https://creativecommons.org/licenses/by-sa/4.0/"
}
],
"modules": [...]
}
- Rules:
- Each period must have
valid-from,valid-to, andnormalized-url. Dates are inclusive on both ends. - The
normalized-urlvalue must be one of the canonical URLs fromlicense-links-normalized.json. If it is not, the module will create a stop folder for any article that would otherwise have used it. - Periods are checked against the article's
issueddate frommetadata-article.json. - If an article's
issueddate does not fall within any defined period, a stop folder is created.
Manual license.json override
This is the last-resort override for individual articles. Use it when neither CrossRef nor the XML contain license info, the publisher does not warrant adding to the single-source list, and no journal-wide license-periods rule applies — but you can determine the license for this one article manually.
-
Where to place it: Inside the previous module folder (e.g.
springer_open_2024-11-07/), in the main directory of the article. -
File structure:
{
"licenseLink": "https://creativecommons.org/licenses/by/4.0/",
"licenseLinkSources": [
"Free-form description of where the license info came from"
]
}
- What the module does with it:
- If
licenseLinkmatches one of the canonicalnormalized_urlvalues fromlicense-links-normalized.json: the article is finalized successfully, andhistory.csvrecords avalidatetask instead of acreatetask. - If the link does not match any canonical URL: a stop folder is created and the operator is notified via the error CSV. (Most likely the URL in your manual file uses a non-normalized format — fix it by writing the canonical form.)
Code reference (Developer)
The module contains two primary Python files:
flow.pytasks.py
flow.py
This file defines the main flow for the license check. The flow loads two maintainer-managed config files from the NAS into memory once, then iterates over all journals and articles in the module context.
check_license_information()
-
Required Parameters:
-
name_of_config_file(str): Name of the configuration file. Default is"config_harvesting.json" -
test_copy(bool): Flag to indicate if it is a test run. Default isTrue -
Context for Use:
-
This function is the main entry point for the license check flow. It dispatches to the appropriate task path: either the existing-
license.jsonvalidation path, or the regular license check path. -
Example Usage:
-
python check_license_information('config_harvesting.json', test_copy=False) -
Example Output:
-
INFO: Module name: check_license_information INFO: Set base path to: /mnt/nas/wdm-test INFO: Module context: [{'ISSN': '2948-2143', 'position': 2, 'previous_module': 'springer_open', ...}] INFO: Loaded 12 license link variants from /mnt/nas/wdm-test/module_config_files/check_license_information/license-links-normalized.json INFO: Publishers with single-source license override: set() INFO: License check passed for s42467-023-00015-y. Link: 'https://creativecommons.org/licenses/by/4.0/'. Case: a. INFO: License check failed for s42467-024-00016-5. Case: b. Error: ...
tasks.py
This file contains the task definitions used in the license check flow. It is responsible for deciding which case applies (a–g) and writing the appropriate output files.
validate_existing_license_json()
-
Required Parameters:
-
temp_current_module_dir(pathlib.Path): Path to the current temp module directory normalized_urls(set): Set of all known normalized URLs fromlicense-links-normalized.json-
normalized_links_path(pathlib.Path): Path to thelicense-links-normalized.jsonfile -
Context for Use:
-
This function handles the early-exit path where a
license.jsonwas placed manually in the previous module folder. It reads thelicenseLinkfrom that file and checks whether it matches one of the knownnormalized_urlvalues. Returns aLicenseCheckResultindicating success or failure. The flow uses this result to decide whether to finalize the article or to create a stop folder. -
Example Usage:
-
python result = validate_existing_license_json(temp_dir, normalized_urls, normalized_links_path) if result.success: # finalize article -
Example Output:
-
On success:
LicenseCheckResult(success=True, case="existing_valid", license_link="https://creativecommons.org/licenses/by/4.0/") - On failure:
LicenseCheckResult(success=False, case="existing_invalid", license_link="<the bad link>")
check_article_license()
-
Required Parameters:
-
temp_current_module_dir(pathlib.Path): Path to the current temp module directory variant_to_normalized(dict): Mapping from each known variant URL to its normalized URLnormalized_urls(set): Set of all known normalized URLsnormalized_links_path(pathlib.Path): Path tolicense-links-normalized.json(used in error messages)publishers_single_source_path(pathlib.Path): Path topublishers_with_single_license_link_source.txtsingle_source_override(bool): True if the current journal's publisher is in the single-source override listlicense_periods(list or None): The journal'slicense-periodslist from the flow config, if any-
config_path(str): Full path to the flow configuration file -
Context for Use:
-
This is the core decision function. It reads license links from both
metadata-article.json(CrossRef) and the full-text XML (XPath//permissions//@xlink:href), normalizes and deduplicates them, then determines which of the seven cases applies (a–g). For successful cases it writeslicense.jsondirectly; for failure cases it writeslicense-error.json. In both situations it returns aLicenseCheckResultthat the flow uses to decide whether to mark the article as stop-processing and what to write tohistory.csv. -
Example Usage:
-
python result = check_article_license( temp_current_module_dir=temp_dir, variant_to_normalized=variant_map, normalized_urls=normalized_set, normalized_links_path=norm_path, publishers_single_source_path=pub_path, single_source_override=False, license_periods=None, config_path=str(config_path), ) -
Example Output:
-
On case a:
LicenseCheckResult(success=True, case="a", license_link="https://creativecommons.org/licenses/by/4.0/", doc_input="metadata-article.json, xml/foo.xml, /mnt/.../license-links-normalized.json", doc_description="All license links from the CrossRef metadata and full text XML are identical.") - On case b:
LicenseCheckResult(success=False, case="b", error_msg="The license links from CrossRef and/or the full-text XML file were not identical or were missing entirely. See the following error file: /mnt/.../license-error.json")
document_check_license_information_error()
-
Required Parameters:
-
module_name(str): Name of the current module latest_previous_module(pathlib.Path): Path to the latest previous module directory-
error_message(str): Human-readable error message describing why the article was stopped -
Context for Use:
-
This function appends an entry to the central error CSV log for any article that ended up in a stop folder.
-
Example Usage:
-
python document_check_license_information_error( module_name='check_license_information', latest_previous_module=prev_module_path, error_message='The license links from CrossRef and/or the full-text XML file were not identical...', )
Lower-level helper functions in tasks.py
load_normalized_links()
-
Required Parameters:
-
data_root(pathlib.Path): Path to the data root (NAS) -
Context for Use:
-
Reads
license-links-normalized.jsonfrom the NAS and returns a tuple of(variant_to_normalized, normalized_urls). The first is a dict mapping each lower-cased variant URL to its canonical normalized URL; the second is a set of all canonical URLs (used to validate manually-written license links and config-override links).
load_publishers_with_single_source()
-
Required Parameters:
-
data_root(pathlib.Path): Path to the data root (NAS) -
Context for Use:
-
Reads
publishers_with_single_license_link_source.txtfrom the NAS line-by-line and returns a set of publisher source-names. Returns an empty set when the file does not exist. Used to apply the override for cases c and e.
get_crossref_license_links()
-
Required Parameters:
-
module_temp_dir(pathlib.Path): Path to the temp directory containingmetadata-article.json -
Context for Use:
-
Returns the list of license URLs from
metadata-article.jsonby delegating tocommon.metadata.get_article_rights. Returns an empty list when no license field is present.
get_xml_license_links()
-
Required Parameters:
-
module_temp_dir(pathlib.Path): Path to the temp directory containing thexml/subfolder -
Context for Use:
-
Locates the first
.xmlfile in thexml/subdirectory, parses it safely (entities disabled, no network access), and extracts allxlink:hrefattributes from<permissions>elements. The XLink namespace is declared explicitly so files using non-xlinkprefixes (e.g. Springer'sns0) still resolve correctly. Returns a tuple of(list_of_hrefs, relative_path_to_xml).
normalize_and_deduplicate()
-
Required Parameters:
-
links(list): Raw license URLs as extracted from CrossRef or XML -
variant_to_normalized(dict): Mapping from variant URLs to normalized URLs -
Context for Use:
-
Strips whitespace, lower-cases each link, replaces it with its normalized URL when a variant match is found (otherwise keeps the lower-cased original), and deduplicates the result. This is the function that decides whether two differently-formatted CC license URLs are treated as the same license.
get_publisher_name_for_issn() / get_license_periods_for_issn()
-
Required Parameters:
-
config_path(str): Path to the flow configuration file -
issn(str): The journal's ISSN -
Context for Use:
-
Walk the flow config to find the journal entry matching the given ISSN. Returns the parent
source-nameand the journal'slicense-periodsarray, if present.
get_article_issued_date()
-
Required Parameters:
-
article_metadata_path(pathlib.Path): Path tometadata-article.json -
Context for Use:
-
Reads the
issuedfield from CrossRef metadata. ReturnsNonewhen the field is absent or unparseable.
get_normalized_url_for_date()
-
Required Parameters:
-
license_periods(list): The journal'slicense-periodsarray from the flow config -
issued_date(datetime.date): The article's issued date -
Context for Use:
-
Iterates the journal's
license-periodsand returns thenormalized-urlwhosevalid-from/valid-torange coversissued_date. ReturnsNonewhen no period covers the date. Used in the case-g config override.
write_license_json()
-
Required Parameters:
-
module_temp_dir(pathlib.Path): Path to the current temp module directory license_link(str): The normalized license URL-
sources(list): Source identifiers (e.g.["metadata-article.json", "xml/foo.xml"]) -
Context for Use:
-
Writes the success output
license.jsoninto the temp module directory. ThelicenseLinkSourcesfield records which source(s) the link was derived from, which differs by case. -
Example Output:
-
json { "licenseLink": "https://creativecommons.org/licenses/by/4.0/", "licenseLinkSources": [ "metadata-article.json", "xml/frpro-02-1320917.xml" ] }
write_license_error_json() / write_license_error_json_from_license_file()
-
Required Parameters:
-
For
write_license_error_json:module_temp_dir,crossref_links(list),xml_links(list),xml_rel_path(str or None) -
For
write_license_error_json_from_license_file:temp_current_module_dir,license_link(str),normalized_links_path(pathlib.Path) -
Context for Use:
-
Writes the failure output
license-error.jsoninto the temp module directory before the stop folder is finalized.write_license_error_jsonis used for the regular cases (b, c-no-override, d, e-no-override, f, g-no-override) and lists both the CrossRef and XML license links.write_license_error_json_from_license_fileis used when a manually placedlicense.jsonfailed validation, and records the failing link plus the path to the variants file.
LicenseCheckResult (dataclass)
-
Fields:
-
success(bool): True if the article passed the license check case(str): One of"a","c","e","g_config","existing_valid", or a failure code like"b","d","f","existing_invalid"license_link(str): The resolved normalized URL (on success)doc_input/doc_description(str): Values for theInputandDescriptioncolumns ofhistory.csv(on success)-
error_msg(str): Human-readable error message (on failure) -
Context for Use:
-
The single value returned by
validate_existing_license_jsonandcheck_article_license. Flow.py readssuccessto branch between finalize and stop, then reads either thedoc_*fields (forhistory.csv) orerror_msg(for the error CSV log).