| 144 |
| 145 |
| 146 |
| 147 |
| 148 |
| 149 |
| 150 |
| 151 |
| 152 |
| 153 |
| 154 |
| 155 |
| 156 |
| 157 |
| 158 |
| 159 |
| 160 |
| 161 |
| 162 |
| 163 | |
def ensure(self, *args, **kwargs): |
""" ensure that an args-joined path exists (by default as |
a file). if you specify a keyword argument 'directory=True' |
then the path is forced to be a directory path. |
""" |
try: |
p = self.join(*args) |
if p.check(): |
if p.check(versioned=False): |
p.add() |
return p |
if kwargs.get('dir', 0): |
return p._ensuredirs() |
parent = p.dirpath() |
parent._ensuredirs() |
-> p.write("") |
p.add() |
return p |
except: |
error_enhance(sys.exc_info()) | |