feeds: replacement code for descriptors

master
pictuga 2018-10-31 22:15:34 +01:00
parent 16f3ffa96e
commit d1aab99b80
1 changed files with 19 additions and 0 deletions

View File

@ -160,6 +160,25 @@ class FeedBase(object):
if match is not None:
return match.getparent().remove(match)
def from_bool(self, x):
return (x or '').lower() != 'false'
def to_bool(self, x):
return 'true' if value else 'false'
def from_time(self, x):
try:
return parse_time(x)
except ValueError:
return None
def to_time(self, x):
try:
time = parse_time(value)
return time.strftime(instance.timeFormat)
except ValueError:
pass
def tostring(self, **k):
""" Returns string using lxml. Arguments passed to tostring """
return etree.tostring(self.xml, **k)