Skip to content

`dir1/file.txt' must be only a file name #104

Description

@jaraco

In GitLab by @omry3 on Jun 24, 2020, 22:59

From https://importlib-resources.readthedocs.io/en/latest/:
"In our terminology, a resource is a file tree that is located within an importable Python package."

Because this is talking about a file tree, I would expect to be able to check for resources in sub directories inside the importable Python package.
This does not seem to be the case.
The example below has two issues I am wondering about:

  1. How do I check if a directory exists?
  2. Why the error dir1/file.txt' must be only a file name? it seems that this should be supported based on the project terminology.

Source tree: test-importlib.zip

Structure:

$ tree
.
├── package
│   ├── dir1
│   │   └── file.txt
│   ├── file.txt
│   └── __init__.py
└── test.py

Output:

$ python test.py 
is_resource("package", "file.txt") True
is_resource("package", "dir1") False , how do I check if a directory exists?
is_resource("package", "dir1/file.txt") failed with dir1/file.txt' must be only a file name'
is_resource("package.dir1", "file.txt") False need an __init__.py in dir1

Thanks.

Activity

  1. jaraco commented on Oct 21, 2020

    @jaraco
    MemberAuthor

    In GitLab by @brettcannon on Jun 25, 2020, 14:10

    marked this issue as related to #58

  2. jaraco commented on Oct 21, 2020

    @jaraco
    MemberAuthor

    In GitLab by @brettcannon on Jun 25, 2020, 14:13

    This is a duplicate of #58

  3. jaraco commented on Oct 21, 2020

    @jaraco
    MemberAuthor

    In GitLab by @brettcannon on Jun 25, 2020, 14:13

    closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions