Improved the get_package_files() function to handle the MultiplexedPath object and avoid the AttributeError.

This commit is contained in:
Paul Gauthier (aider) 2024-07-04 15:07:49 -03:00
parent 4ad6eef1a3
commit 4030fdb574

View file

@ -15,10 +15,16 @@ warnings.simplefilter("ignore", category=FutureWarning)
def get_package_files(): def get_package_files():
website_files = importlib_resources.files('website') website_files = importlib_resources.files('website')
for path in website_files.rglob('*.md'): for path in importlib_resources.files('website').iterdir():
if path.is_file() and path.name.endswith('.md'):
if not any(part.startswith(('OLD', 'tmp')) or part in ('examples', '_posts') for part in path.parts): if not any(part.startswith(('OLD', 'tmp')) or part in ('examples', '_posts') for part in path.parts):
dump(path) dump(path)
yield str(path) yield str(path)
elif path.is_dir():
for subpath in path.rglob('*.md'):
if not any(part.startswith(('OLD', 'tmp')) or part in ('examples', '_posts') for part in subpath.parts):
dump(subpath)
yield str(subpath)
def fname_to_url(filepath): def fname_to_url(filepath):