Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow resources to be in subdirectories #58

Closed
Labels
enhancementNew feature or request
Milestone
@jaraco

Description

@jaraco

In GitLab by @rob.speer on May 16, 2018, 01:23

Suppose I have a Web application,myapp, that needs to serve a static file, which by convention needs to be in the pathmyapp/static/ld/context.ld.json. Suppose I also want to be able to access that file from Python code, because its contents are used in a test.

As importlib_resources is currently defined, I would need to rewrite the path as if it were a Python submodule, even though it does not contain actual Python code:path(myapp.static.ld, "context.ld.json"). I would also need to create empty files namedmyapp/static/__init__.py andmyapp/static/ld/__init__.py, and hopefully exclude them from being served as static files.

That would be enough for me to give up and use paths relative to__file__ instead. In general, I would heartily recommend importlib if I could reasonably promise that it was an improvement over using__file__ or over existing uses ofpkg_resources, which it wouldn't be if it doesn't support subdirectories.

The call I would like to be able to make in this situation ispath(myapp, "static/ld/context.ld.json").

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp