diff --git a/frontools/sources.py b/frontools/sources.py index c83cc61..0e948d4 100644 --- a/frontools/sources.py +++ b/frontools/sources.py @@ -1,6 +1,7 @@ """Source for remote files""" from abc import ABC, abstractmethod from contextlib import asynccontextmanager +from pathlib import Path from re import Pattern from re import compile as re_compile from typing import AsyncGenerator, AsyncIterable, Optional, cast @@ -132,9 +133,10 @@ class OverrideSource(Source): for pattern, replace in self._mappings: if pattern.match(url): - mapped_path = pattern.sub(replace, url) - with open(mapped_path, "rb") as mapped_file: - return mapped_file.read() + mapped_path = Path(pattern.sub(replace, url)) + if mapped_path.is_file(): + with open(mapped_path, "rb") as mapped_file: + return mapped_file.read() return await self._next_source.get_url(url)