xsdata.utils.downloader module

class xsdata.utils.downloader.Downloader(output)[source]

Bases: object

Helper class to download a schema or a definitions with all their imports locally. The imports paths will be adjusted if necessary.

Parameters

output (Path) – Output path

output: pathlib.Path
base_path: Optional[pathlib.Path] = None
downloaded: Dict
wget(uri, location=None)[source]

Download handler for any uri input with circular protection.

Parameters
parse_schema(uri, content)[source]

Convert content to a schema instance and process all sub imports.

Parameters
parse_definitions(uri, content)[source]

Convert content to a definitions instance and process all sub imports.

Parameters
wget_included(definition)[source]
Parameters

definition (Union[Schema, Definitions]) –

adjust_base_path(uri)[source]

Adjust base path for every new uri loaded.

Example runs:
Parameters

uri (str) –

adjust_imports(path, content)[source]

Try to adjust the import locations for external locations that are not relative to the first requested uri.

Parameters
  • path (Path) –

  • content (str) –

Return type

str

write_file(uri, location, content)[source]

Write the given uri and it’s content according to the base path and if the uri is relative to first requested uri.

Keep track of all the written file paths, in case we have to modify the location attribute in an upcoming schema/definition import.

Parameters