Let directories @size property work also.

I was hesitant at first because of course it can be slow to run,
but previously you'd have to have an if so that you know whether you've
got int or none corresponding to files and folders anyway, so I don't
think the caller-side complexity is increased at all, and saves me from
having to write this as a helper function outside the class.
Only for special cases like preparing to handle permissionerror
would you need to use your own function.
This commit is contained in:
Ethan Dalool 2020-03-12 18:18:59 -07:00
parent 081313d7ef
commit 417c14a023

View file

@ -236,7 +236,7 @@ class Path:
if self.is_file: if self.is_file:
return os.path.getsize(self.absolute_path) return os.path.getsize(self.absolute_path)
else: else:
return None return sum(file.size for file in self.walk() if file.is_file)
def spawn(self, path): def spawn(self, path):
return self.__class__(path, force_sep=self.force_sep) return self.__class__(path, force_sep=self.force_sep)