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:
parent
081313d7ef
commit
417c14a023
1 changed files with 1 additions and 1 deletions
|
@ -236,7 +236,7 @@ class Path:
|
|||
if self.is_file:
|
||||
return os.path.getsize(self.absolute_path)
|
||||
else:
|
||||
return None
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue