mirror of
https://github.com/python/cpython.git
synced 2025-08-13 05:19:08 +00:00
16 lines
550 B
Python
16 lines
550 B
Python
from .api import Distribution
|
|
from contextlib import suppress
|
|
|
|
|
|
class PathDistribution(Distribution):
|
|
def __init__(self, path):
|
|
"""Construct a distribution from a path to the metadata directory."""
|
|
self._path = path
|
|
|
|
def read_text(self, filename):
|
|
with suppress(FileNotFoundError, NotADirectoryError, KeyError):
|
|
return self._path.joinpath(filename).read_text(encoding='utf-8')
|
|
read_text.__doc__ = Distribution.read_text.__doc__
|
|
|
|
def locate_file(self, path):
|
|
return self._path.parent / path
|