Ensure that an args-joined path exists (by default as a file). if you specify a keyword argument 'dir=True' then the path is forced to be a directory path.
(self, *args, **kwargs)
| 945 | return self |
| 946 | |
| 947 | def ensure(self, *args, **kwargs): |
| 948 | class="st">"""Ensure that an args-joined path exists (by default as |
| 949 | a file). if you specify a keyword argument &class="cm">#x27;dir=True' |
| 950 | then the path is forced to be a directory path. |
| 951 | class="st">""" |
| 952 | p = self.join(*args) |
| 953 | if kwargs.get(class="st">"dir", 0): |
| 954 | return p._ensuredirs() |
| 955 | else: |
| 956 | p.dirpath()._ensuredirs() |
| 957 | if not p.check(file=1): |
| 958 | p.open(class="st">"wb").close() |
| 959 | return p |
| 960 | |
| 961 | @overload |
| 962 | def stat(self, raising: Literal[True] = ...) -> Stat: ... |