Commit 7c4f7f58 authored by Philipp Hörist's avatar Philipp Hörist

VCard: Add is_empty() for properties

parent b3a81423
......@@ -373,6 +373,10 @@ class UriProperty:
node.addChild('uri', payload=self.value)
return node
@property
def is_empty(self):
return not self.value
@dataclass
class TextProperty:
......@@ -402,6 +406,10 @@ class TextProperty:
node.addChild('text', payload=self.value)
return node
@property
def is_empty(self):
return not self.value
@dataclass
class TextListProperty:
......@@ -435,6 +443,10 @@ class TextListProperty:
add_children(node, 'text', self.values)
return node
@property
def is_empty(self):
return not self.values
@dataclass
class MultipleValueProperty:
......@@ -464,6 +476,10 @@ class MultipleValueProperty:
node.addChild(self.value_type, payload=self.value)
return node
@property
def is_empty(self):
return not self.value
@dataclass
class SourceProperty(UriProperty):
......@@ -538,6 +554,16 @@ class NProperty:
add_children(node, 'suffix', self.suffix)
return node
@property
def is_empty(self):
if (self.surname or
self.given or
self.additional or
self.suffix or
self.prefix):
return False
return True
@dataclass
class NicknameProperty(TextListProperty):
......@@ -599,6 +625,12 @@ class GenderProperty:
node.addChild('identity', payload=self.sex)
return node
@property
def is_empty(self):
if self.sex or self.identity:
return False
return True
@dataclass
class AdrProperty:
......@@ -645,6 +677,18 @@ class AdrProperty:
add_children(node, 'country', self.country)
return node
@property
def is_empty(self):
if (self.pobox or
self.ext or
self.street or
self.locality or
self.region or
self.code or
self.country):
return False
return True
@dataclass
class TelProperty(MultipleValueProperty):
......@@ -692,6 +736,10 @@ class LangProperty:
node.addChild('language-tag', payload=self.value)
return node
@property
def is_empty(self):
return not self.value
@dataclass
class TzProperty(MultipleValueProperty):
......@@ -832,6 +880,10 @@ class ClientpidmapProperty:
node.addChild('uri', payload=self.uri)
return node
@property
def is_empty(self):
return not self.uri
@dataclass
class UrlProperty(UriProperty):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment