Create directories for .props as well.
This commit is contained in:
parent
537d6b6fd2
commit
1510e6c194
@ -295,13 +295,17 @@ class Calendar(object):
|
|||||||
Header("VERSION:2.0"))
|
Header("VERSION:2.0"))
|
||||||
items = items if items is not None else self.items
|
items = items if items is not None else self.items
|
||||||
|
|
||||||
# Create folder if absent
|
self._create_dirs(self.path)
|
||||||
if not os.path.exists(os.path.dirname(self.path)):
|
|
||||||
os.makedirs(os.path.dirname(self.path))
|
|
||||||
|
|
||||||
text = serialize(headers, items)
|
text = serialize(headers, items)
|
||||||
return open(self.path, "w").write(text)
|
return open(self.path, "w").write(text)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _create_dirs(path):
|
||||||
|
"""Create folder if absent."""
|
||||||
|
if not os.path.exists(os.path.dirname(path)):
|
||||||
|
os.makedirs(os.path.dirname(path))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def etag(self):
|
def etag(self):
|
||||||
"""Etag from calendar."""
|
"""Etag from calendar."""
|
||||||
@ -392,6 +396,7 @@ class Calendar(object):
|
|||||||
properties.update(json.load(prop_file))
|
properties.update(json.load(prop_file))
|
||||||
yield properties
|
yield properties
|
||||||
# on exit
|
# on exit
|
||||||
|
self._create_dirs(props_path)
|
||||||
with open(props_path, 'w') as prop_file:
|
with open(props_path, 'w') as prop_file:
|
||||||
json.dump(properties, prop_file)
|
json.dump(properties, prop_file)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user