weldx.asdf.extension.WeldxExtension.url_mapping

property WeldxExtension.url_mapping

A list of 2-tuples or callables mapping JSON Schema URLs to other URLs. This is useful if the JSON Schemas are not actually fetchable at their corresponding URLs but are on the local filesystem, or, to save bandwidth, we have a copy of fetchable schemas on the local filesystem. If neither is desirable, it may simply be the empty list.

For each entry:

  • If a 2-tuple, the first part is a URL prefix to match. The second part is a string, where the following are available as Python formatting tokens:

    • {url}: The entire JSON schema URL

    • {url_prefix}: The matched URL prefix

    • {url_suffix}: The part of the URL after the prefix.

  • If a callable, it is passed the entire JSON Schema URL and must return a resolvable URL pointing to the schema content. If it doesn’t match, should return None.

For example, to map a remote HTTP URL prefix to files installed alongside as data alongside Python module:

return [('http://nowhere.org/schemas/custom/1.0.0/',
        asdf.util.filepath_to_url(
            os.path.join(SCHEMA_PATH, 'stsci.edu')) +
        '/{url_suffix}.yaml'
       )]