join

join(key: str, *subkeys: str, name: str | None = None, ensure_exists: bool = True, version: None | str | Callable[[], str | None] = None) Path[source]

Return the home data directory for the given module.

Parameters:
  • key – The name of the module. No funny characters. The envvar <key>_HOME where key is uppercased is checked first before using the default home directory.

  • subkeys – A sequence of additional strings to join

  • name – The name of the file (optional) inside the folder

  • ensure_exists – Should all directories be created automatically? Defaults to true.

  • version

    The optional version, or no-argument callable that returns an optional version. This is prepended before the subkeys.

    The following example describes how to store the versioned data from the Rhea database for biologically relevant chemical reactions.

    import pystow
    import requests
    
    def get_rhea_version() -> str:
        res = requests.get("https://ftp.expasy.org/databases/rhea/rhea-release.properties")
        _, _, version = res.text.splitlines()[0].partition("=")
        return version
    
    # Assume you want to download the data from
    # ftp://ftp.expasy.org/databases/rhea/rdf/rhea.rdf.gz, make a path
    # with the same name
    path = pystow.join("rhea", name="rhea.rdf.gz", version=get_rhea_version)
    

Returns:

The path of the directory or subdirectory for the given module.