Create the directory structure if none found.
This commit is contained in:
parent
3bc3574105
commit
537d6b6fd2
@ -185,16 +185,20 @@ class Calendar(object):
|
|||||||
path = "/".join(attributes[:min(len(attributes), 2)])
|
path = "/".join(attributes[:min(len(attributes), 2)])
|
||||||
path = path.replace("/", os.sep)
|
path = path.replace("/", os.sep)
|
||||||
abs_path = os.path.join(FOLDER, path)
|
abs_path = os.path.join(FOLDER, path)
|
||||||
if os.path.isdir(abs_path):
|
if os.path.isdir(abs_path) or len(attributes) == 1:
|
||||||
if depth == "0":
|
if depth == "0":
|
||||||
result.append(cls(path, principal=True))
|
result.append(cls(path, principal=True))
|
||||||
else:
|
else:
|
||||||
if include_container:
|
if include_container:
|
||||||
result.append(cls(path, principal=True))
|
result.append(cls(path, principal=True))
|
||||||
for f in next(os.walk(abs_path))[2]:
|
try:
|
||||||
f_path = os.path.join(path, f)
|
for f in next(os.walk(abs_path))[2]:
|
||||||
if cls.is_vcalendar(os.path.join(abs_path, f)):
|
f_path = os.path.join(path, f)
|
||||||
result.append(cls(f_path))
|
if cls.is_vcalendar(os.path.join(abs_path, f)):
|
||||||
|
result.append(cls(f_path))
|
||||||
|
except StopIteration:
|
||||||
|
# directory does not exist yet
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
calendar = cls(path)
|
calendar = cls(path)
|
||||||
if depth == "0":
|
if depth == "0":
|
||||||
@ -284,6 +288,8 @@ class Calendar(object):
|
|||||||
|
|
||||||
def write(self, headers=None, items=None):
|
def write(self, headers=None, items=None):
|
||||||
"""Write calendar with given parameters."""
|
"""Write calendar with given parameters."""
|
||||||
|
if self.is_principal:
|
||||||
|
return
|
||||||
headers = headers or self.headers or (
|
headers = headers or self.headers or (
|
||||||
Header("PRODID:-//Radicale//NONSGML Radicale Server//EN"),
|
Header("PRODID:-//Radicale//NONSGML Radicale Server//EN"),
|
||||||
Header("VERSION:2.0"))
|
Header("VERSION:2.0"))
|
||||||
|
Loading…
Reference in New Issue
Block a user