Skip to content

Expose resource roots #125

@Thom1729

Description

@Thom1729

In order to implement ResourcePath.from_file_path() and Resource_path.file_path(), we internally keep a list of ResourceRoot objects. Exposing these roots could allow users to answer various tricky questions about resources:

  • Is a given resource from a zipped or unzipped package?
  • Does a given resource have overrides?
  • When was a given resource last modified?

This functionality could be useful for packages like OverrideAudit. In addition, it could be used to implement resource caching (#24): a resource must be reloaded if either the modification time or the resource root has changed.

As a first thought, a resource root could support the following operations:

  • resource_to_file_path(path) -> Path (already implemented)
  • file_to_resource_path(path) -> ResourcePath (already implemented)
  • resource_exists(path) → boolean
  • resource_modified(path) → timestamp
  • load_resource(path) → string
  • load_binary_resource(path) → bytes

The following operation would be provided at the ResourcePath level (or perhaps in a new class?):

  • roots_providing_resource(path) → List[ResourceRoot]

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions