MCPcopy
hub / github.com/pimutils/vdirsyncer / checkdir

Function checkdir

vdirsyncer/utils.py:117–133  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

115
116
117def 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
136def checkfile(path, create=False):

Callers 6

checkfileFunction · 0.85
__init__Method · 0.85
create_collectionMethod · 0.85
_set_auth_tokenMethod · 0.85
_set_keyMethod · 0.85
_save_tokenMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected