Check whether ``path`` is a directory. :param create: Whether to create the directory (and all parent directories) if it does not exist. :param mode: Mode to create missing directories with.
(path, create=False, mode=0o750)
| 115 | |
| 116 | |
| 117 | def checkdir(path, create=False, mode=0o750): |
| 118 | ''' |
| 119 | Check whether ``path`` is a directory. |
| 120 | |
| 121 | :param create: Whether to create the directory (and all parent directories) |
| 122 | if it does not exist. |
| 123 | :param mode: Mode to create missing directories with. |
| 124 | ''' |
| 125 | |
| 126 | if not os.path.isdir(path): |
| 127 | if os.path.exists(path): |
| 128 | raise OSError('{} is not a directory.'.format(path)) |
| 129 | if create: |
| 130 | os.makedirs(path, mode) |
| 131 | else: |
| 132 | raise exceptions.CollectionNotFound('Directory {} does not exist.' |
| 133 | .format(path)) |
| 134 | |
| 135 | |
| 136 | def checkfile(path, create=False): |
no outgoing calls
no test coverage detected