Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jaraco opened this issue Oct 21, 2020 · 3 comments
Closed

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

jaraco opened this issue Oct 21, 2020 · 3 comments

Comments

@jaraco
Copy link
Member

jaraco commented Oct 21, 2020

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.

@jaraco
Copy link
Member Author

jaraco commented Oct 21, 2020

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

marked this issue as related to #58

@jaraco
Copy link
Member Author

jaraco commented Oct 21, 2020

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

This is a duplicate of #58

@jaraco
Copy link
Member Author

jaraco commented Oct 21, 2020

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

closed

@jaraco jaraco closed this as completed Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant