Only set the principal tag for root folders (related to #580)

This commit is contained in:
Guillaume Ayoub 2011-09-25 21:15:17 +02:00
parent 160e296ed1
commit e545df5722

View File

@ -208,12 +208,13 @@ class Calendar(object):
path = "/".join(attributes) path = "/".join(attributes)
abs_path = os.path.join(FOLDER, path.replace("/", os.sep)) abs_path = os.path.join(FOLDER, path.replace("/", os.sep))
principal = len(attributes) <= 1
if os.path.isdir(abs_path): if os.path.isdir(abs_path):
if depth == "0": if depth == "0":
result.append(cls(path, principal=True)) result.append(cls(path, principal))
else: else:
if include_container: if include_container:
result.append(cls(path, principal=True)) result.append(cls(path, principal))
try: try:
for filename in next(os.walk(abs_path))[2]: for filename in next(os.walk(abs_path))[2]:
if cls.is_vcalendar(os.path.join(abs_path, filename)): if cls.is_vcalendar(os.path.join(abs_path, filename)):
@ -225,7 +226,7 @@ class Calendar(object):
if depth == "0": if depth == "0":
result.append(cls(path)) result.append(cls(path))
else: else:
calendar = cls(path, principal=True) calendar = cls(path, principal)
if include_container: if include_container:
result.append(calendar) result.append(calendar)
result.extend(calendar.components) result.extend(calendar.components)