Ejemplo n.º 1
0
    def get_entry(self, Report):
        delimiter = ','

        photo_filename = ''
        photo_source = ''

        date_str = Report.get_date()
        tgeu_date_str = date_str

        try:
            dt = datetime.strptime(date_str, '%Y-%m-%d')  # 2017-11-20
            tgeu_date_str = dt.strftime('%d-%b-%Y')  # 20-Nov-2017
        except ValueError:
            dt = None

        birthdate = ''
        source_ref = 'tgeu/' + tgeu_date_str + '/' + Report.get_name()
        location = self.get_location_from_location_string(
            Report.get_location())
        state = self.get_state_from_location_string(Report.get_location())
        country = self.get_country_from_location_string(Report.get_location())
        latitude = ''
        longitude = ''
        category = self.get_category_from_cause(Report.get_cause())
        description = Report.get_remarks() + '\n\n' + Report.get_source()
        tweet = ''

        text = (self.quote_if_necessary(Report.get_name()) + delimiter +
                self.quote_if_necessary(Report.get_age()) + delimiter +
                self.quote_if_necessary(birthdate) + delimiter +
                self.quote_if_necessary(photo_filename) + delimiter +
                self.quote_if_necessary(photo_source) + delimiter +
                self.quote_if_necessary(date_str) + delimiter +
                self.quote_if_necessary(source_ref) + delimiter +
                self.quote_if_necessary(location) + delimiter +
                self.quote_if_necessary(state) + delimiter +
                self.quote_if_necessary(country) + delimiter +
                self.quote_if_necessary(latitude) + delimiter +
                self.quote_if_necessary(longitude) + delimiter +
                self.quote_if_necessary(category) + delimiter +
                self.quote_if_necessary(Report.get_cause()) + delimiter +
                self.quote_if_necessary(description) + delimiter +
                self.quote_if_necessary(tweet) + delimiter)

        return text