Check whether ``path`` is a file. :param create: Whether to create the file's parent directories if they do not exist.
(path, create=False)
| 134 | |
| 135 | |
| 136 | def checkfile(path, create=False): |
| 137 | ''' |
| 138 | Check whether ``path`` is a file. |
| 139 | |
| 140 | :param create: Whether to create the file's parent directories if they do |
| 141 | not exist. |
| 142 | ''' |
| 143 | checkdir(os.path.dirname(path), create=create) |
| 144 | if not os.path.isfile(path): |
| 145 | if os.path.exists(path): |
| 146 | raise OSError('{} is not a file.'.format(path)) |
| 147 | if create: |
| 148 | with open(path, 'wb'): |
| 149 | pass |
| 150 | else: |
| 151 | raise exceptions.CollectionNotFound('File {} does not exist.' |
| 152 | .format(path)) |
| 153 | |
| 154 | |
| 155 | class cached_property: |
no test coverage detected