MCPcopy Index your code
hub / github.com/pimutils/vdirsyncer / checkfile

Function checkfile

vdirsyncer/utils.py:136–152  ·  view source on GitHub ↗

Check whether ``path`` is a file. :param create: Whether to create the file's parent directories if they do not exist.

(path, create=False)

Source from the content-addressed store, hash-verified

134
135
136def 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
155class cached_property:

Callers 2

__init__Method · 0.85
create_collectionMethod · 0.85

Calls 1

checkdirFunction · 0.85

Tested by

no test coverage detected