def parse_timestamp(timestamp, time_format=None):
 if (time_format is None):
  time_format = '%a, %d %b %Y %H:%M:%S %Z'
 try:
  return time.strptime(timestamp, time_format)
 except ValueError:
  try:
   return time.strptime(re.sub(' \\w+$', '', timestamp), time_format.replace(' %Z', ''))
  except ValueError:
   LOG.error(('Failed to convert Oozie timestamp: %s' % time_format))
 except Exception:
  LOG.error(('Failed to convert Oozie timestamp: %s' % time_format))
 return None

def parse_timestamp ( timestamp , time_format = None ) : if ( time_format is None ) : time_format = '%a, %d %b %Y %H:%M:%S %Z' try : return time . strptime ( timestamp , time_format ) except ValueError : try : return time . strptime ( re . sub ( ' \\w+$' , '' , timestamp ) , time_format . replace ( ' %Z' , '' ) ) except ValueError : LOG . error ( ( 'Failed to convert Oozie timestamp: %s' % time_format ) ) except Exception : LOG . error ( ( 'Failed to convert Oozie timestamp: %s' % time_format ) ) return None
parse_timestamp -> struct_time does not raise valueerror .