Resource Scanning APIs

The oxidized_importer module exposes functions and Python types to facilitate scanning for and collecting Python resources.

find_resources_in_path(path)

This function scans a filesystem path and returns discovered resources. See find_resources_in_path() for the API documentation.

To discover all filesystem based resources that Python’s PathFinder meta path finder would (with the exception of .zip files), try the following:

import os
import oxidized_importer
import sys

resources = []
for path in sys.path:
    if os.path.isdir(path):
        resources.extend(oxidized_importer.find_resources_in_path(path))

OxidizedResourceCollector Python Type

The OxidizedResourceCollector type provides functionality for turning instances of Python resource types into a collection of OxidizedResource for loading into an OxidizedFinder instance. It exists as a convenience, as working with individual OxidizedResource instances can be rather cumbersome.

To create a collector that only marks resources for in-memory loading:

import oxidized_importer

collector = oxidized_importer.OxidizedResourceCollector(
    allowed_locations=["in-memory"]
)