From 426da9b52b4bd2b982b003848e59cd6a07b2bad3 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 28 Oct 2020 14:56:52 -0700 Subject: [PATCH] Let listdir spawn children with _correct_case already set. --- voussoirkit/pathclass.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/voussoirkit/pathclass.py b/voussoirkit/pathclass.py index 2fb9665..797ea24 100644 --- a/voussoirkit/pathclass.py +++ b/voussoirkit/pathclass.py @@ -195,7 +195,8 @@ class Path: def listdir(self): children = os.listdir(self.absolute_path) - children = [self.with_child(child) for child in children] + children = [os.path.join(self.absolute_path, child) for child in children] + children = [self.spawn(child, _case_correct=self._case_correct) for child in children] return children def makedirs(self, mode=0o777, exist_ok=False): @@ -220,8 +221,6 @@ class Path: return self.relative_to(os.getcwd()) def relative_to(self, other, simple=False): - other = self.spawn(other) - if self == other: return '.' @@ -269,8 +268,8 @@ class Path: elif self.is_dir: return sum(file.size for file in self.walk() if file.is_file) - def spawn(self, path): - return self.__class__(path, force_sep=self.force_sep) + def spawn(self, path, **kwargs): + return self.__class__(path, force_sep=self.force_sep, **kwargs) @property def stat(self):