ensure_xml

ensure_xml(key, *subkeys, url, name=None, force=False, download_kwargs=None, parse_kwargs=None)[source]

Download an XML file and open it with lxml.

Parameters:
  • key (str) – The module name

  • subkeys (str) – A sequence of additional strings to join. If none are given, returns the directory for this module.

  • url (str) – The URL to download.

  • name (Optional[str]) – Overrides the name of the file at the end of the URL, if given. Also useful for URLs that don’t have proper filenames with extensions.

  • force (bool) – Should the download be done again, even if the path already exists? Defaults to false.

  • download_kwargs (Optional[Mapping[str, Any]]) – Keyword arguments to pass through to pystow.utils.download().

  • parse_kwargs (Optional[Mapping[str, Any]]) – Keyword arguments to pass through to lxml.etree.parse().

Return type:

ElementTree

Returns:

An ElementTree object

Warning

If you have lots of files to read in the same archive, it’s better just to unzip first.