def to_i(self, arg):
for subtree in self.tree.subtrees():
if subtree.label() == 'metadata':
self.metadata_text(subtree)
if subtree.label()[:-4] == self.metadata_name:
self.dictionary['metadata'] = self.metadata_name
if subtree.label() == 'todayItem':
self.today(subtree)
if subtree.label() == 'tomorrowItem':
self.tommorow(subtree)
if subtree.label() == 'yesterdayItem':
self.yesterday(subtree)
if subtree.label() == 'middayItem':
self.noon(subtree)
if subtree.label() == 'midnightItem':
self.midnight(subtree)
if 'DayOfWeekItem' in subtree.label():
self.nth_day_of_week(subtree)
if subtree.label() == 'dayValueItem':
self.dictionary['day'] = ' '.join(subtree.leaves())
if subtree.label() == 'monthValueItem':
self.dictionary['month'] = ' '.join(subtree.leaves())
if (('day' in self.dictionary) or ('month' in self.dictionary)):
dateStr = ''
if ('day' in self.dictionary):
dateStr += self.dictionary['day'] + ' '
if ('month' in self.dictionary):
dateStr += self.dictionary['month'] + ' '
dateParser = dateparser.parse(dateStr)
dateTimestamp = mktime(dateParser.timetuple())
self.dictionary['timestamp'] = dateTimestamp
if ('hours' in self.dictionary):
self.dictionary['timestamp'] += int(self.dictionary['hours']) * 3600
return self.dictionary
评论列表
文章目录