Skip to content

file_accessor

FileAccessor, for standardizing access to antelope resources on a filesystem having the following structure:

{DATA ROOT}/[origin]/[interface]/[ds_type]/[source_file] - source {DATA ROOT}/[origin]/[interface]/[ds_type]/config.json - configuration

A filesystem having this structure will enable automatic registration of resources, taking origin, interface, and ds_type from the directory structure and the source+config files as-discovered by traversing the filesystem.

Should probably alter gen_sources to only return the one "best" source per path, instead of generating all of them. [One] problem with that is that, for instance, for Tarjan background I would need to ignore files that end with ORDERING_SUFFIX, but I can't import anything from antelope_background without creating a dependency loop.

For now, generating the sources is probably fine.

FileAccessor

Bases: object

source(org, iface)

Return the "best" (right now: first) single source

Parameters:

Name Type Description Default
org
required
iface
required

Returns:

Type Description

write_config(source, **kwargs) staticmethod

Note: use the config argument add_interfaces=[list] to allow a resource to implement additional interfaces.

Parameters:

Name Type Description Default
source
required
kwargs
{}

Returns:

Type Description

ResourceLoader

Bases: FileAccessor

This class crawls a directory structure and adds all the specified resources to the catalog provided as an input argument.

After loading all pre-initialized resources, the class runs check_bg on each origin to auto-generate a background ordering within the catalog's filespace if one does not already exist.

load_resources(cat, origin=None, check=False, replace=True)

For named origin (or all origins), load resources into the catalog. this will not open the resources, unless check=True

Parameters:

Name Type Description Default
cat
required
origin
None
check

[False] whether to load the resources and check background

False
replace

[True] whether to replace an existing resource with the new one

True

Returns:

Type Description