Temporarily restore python 3.6.0 support

This commit is contained in:
Anthony Sottile 2020-02-24 09:02:19 -08:00
parent 1c641b1c28
commit 081f3028ee
5 changed files with 79 additions and 55 deletions

View file

@ -6,12 +6,21 @@ from typing import Tuple
class Prefix(NamedTuple):
prefix_dir: str
def path(self, *parts: str) -> str:
return os.path.normpath(os.path.join(self.prefix_dir, *parts))
def exists(self, *parts: str) -> bool:
return os.path.exists(self.path(*parts))
def Prefix_path(self, *parts: str) -> str:
return os.path.normpath(os.path.join(self.prefix_dir, *parts))
def star(self, end: str) -> Tuple[str, ...]:
paths = os.listdir(self.prefix_dir)
return tuple(path for path in paths if path.endswith(end))
def Prefix_exists(self, *parts: str) -> bool:
return os.path.exists(self.path(*parts))
def Prefix_star(self, end: str) -> Tuple[str, ...]:
paths = os.listdir(self.prefix_dir)
return tuple(path for path in paths if path.endswith(end))
# python 3.6.0 does not support methods on `typing.NamedTuple`
Prefix.path = Prefix_path
Prefix.exists = Prefix_exists
Prefix.star = Prefix_star