Example #1
0
 def __value_to_dollars(self, transaction):
     try:
         value = transaction.find('value')
         currency = value.get('currency') or self.element.get(
             'default-currency')
         if currency == 'USD': return self.__create_decimal(value.text)
         try:
             year = datetime.datetime.strptime(
                 value.get('value-date').strip('Z'), "%Y-%m-%d").year
         except AttributeError:
             try:
                 if self.strict: raise AttributeError
                 year = datetime.datetime.strptime(
                     transaction.find('transaction-date').get(
                         'iso-date').strip('Z'), "%Y-%m-%d").year
             except AttributeError:
                 debug(self, 'Transaction without date information')
                 return Decimal(0.0)
         if year == 2013: year = 2012
         return toUSD(value=self.__create_decimal(value.text),
                      currency=currency,
                      year=year)
     except Exception, e:
         debug(self, e)
         return Decimal(0.0)
Example #2
0
 def __get_start_year(self):
     activity_date = self.element.find("activity-date[@type='start-actual']")
     if activity_date is None: activity_date = self.element.find("activity-date[@type='start-planned']")
     if activity_date is not None and activity_date.get('iso-date'):
         try:
             date = datetime.datetime.strptime(activity_date.get('iso-date').strip('Z'), "%Y-%m-%d")
             return int(date.year)
         except ValueError, e:
             debug(self, e)
         except AttributeError, e:
             debug(self, e)
Example #3
0
 def __get_start_year(self):
     activity_date = self.element.find(
         "activity-date[@type='start-actual']")
     if activity_date is None:
         activity_date = self.element.find(
             "activity-date[@type='start-planned']")
     if activity_date is not None and activity_date.get('iso-date'):
         try:
             date = datetime.datetime.strptime(
                 activity_date.get('iso-date').strip('Z'), "%Y-%m-%d")
             return int(date.year)
         except ValueError, e:
             debug(self, e)
         except AttributeError, e:
             debug(self, e)
Example #4
0
 def __value_to_dollars(self, transaction):
     try:
         value = transaction.find('value')
         currency = value.get('currency') or self.element.get('default-currency')
         if currency == 'USD': return self.__create_decimal(value.text)
         try:
             year = datetime.datetime.strptime(value.get('value-date').strip('Z'), "%Y-%m-%d").year
         except AttributeError:
             try:
                 if self.strict: raise AttributeError
                 year = datetime.datetime.strptime(transaction.find('transaction-date').get('iso-date').strip('Z'), "%Y-%m-%d").year
             except AttributeError:
                 debug(self, 'Transaction without date information')
                 return Decimal(0.0)
         if year == 2013: year = 2012
         return toUSD(value=self.__create_decimal(value.text),
                      currency=currency,
                      year=year)
     except Exception, e:
         debug(self, e)
         return Decimal(0.0)