Answer addressbook-home-set, fix the collection children detection
This commit is contained in:
parent
b56db741f4
commit
f11e78a3f4
@ -230,8 +230,9 @@ class Collection(object):
|
|||||||
result.append(cls(path, principal))
|
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_collection(os.path.join(abs_path, filename)):
|
collection = cls(os.path.join(path, filename))
|
||||||
result.append(cls(os.path.join(path, filename)))
|
if collection.exists:
|
||||||
|
result.append(collection)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
# Directory does not exist yet
|
# Directory does not exist yet
|
||||||
pass
|
pass
|
||||||
@ -245,11 +246,12 @@ class Collection(object):
|
|||||||
result.extend(collection.components)
|
result.extend(collection.components)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def is_collection(self, path):
|
@property
|
||||||
"""Return ``True`` if there is a collection file under ``path``."""
|
def exists(self):
|
||||||
|
"""Return ``True`` if there is a collection file exists."""
|
||||||
beginning_string = 'BEGIN:%s' % self.tag
|
beginning_string = 'BEGIN:%s' % self.tag
|
||||||
with open(path) as stream:
|
with open(self.path) as stream:
|
||||||
beginning_string = stream.read(len(beginning_string))
|
return beginning_string == stream.read(len(beginning_string))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def items(self):
|
def items(self):
|
||||||
|
@ -242,6 +242,7 @@ def _propfind_response(path, item, props, user):
|
|||||||
elif tag in (
|
elif tag in (
|
||||||
_tag("D", "principal-collection-set"),
|
_tag("D", "principal-collection-set"),
|
||||||
_tag("C", "calendar-user-address-set"),
|
_tag("C", "calendar-user-address-set"),
|
||||||
|
_tag("CR", "addressbook-home-set"),
|
||||||
_tag("C", "calendar-home-set")):
|
_tag("C", "calendar-home-set")):
|
||||||
tag = ET.Element(_tag("D", "href"))
|
tag = ET.Element(_tag("D", "href"))
|
||||||
tag.text = path
|
tag.text = path
|
||||||
|
Loading…
Reference in New Issue
Block a user