def create_umlaut_author(self): umlaut_author = Author() umlaut_author.name = self.umlaut_author_name umlaut_author.domain = self._domain umlaut_author.author_guid = self.author_guid umlaut_author.author_full_name = self.umlaut_author_full_name umlaut_author.description = self.umlaut_author_description umlaut_author.language = self.umlaut_language umlaut_author.location = self.umlaut_location return umlaut_author
def owner_to_author(self, jsonresponse): author = Author() author.name = str(jsonresponse['photo']['owner']['username']) author.author_full_name = str( jsonresponse['photo']['owner']['realname']) author.domain = str(jsonresponse['photo']['id']) author.created_at = str(jsonresponse['photo']['dates']["posted"]) author.author_osn_id = str(jsonresponse['photo']['owner']['nsid']) author.author_guid = compute_author_guid_by_author_name( author.author_osn_id) author.location = str(jsonresponse['photo']['owner']['location']) author.author_type = 'owner' return author
def parse_row(self, row): try: author = Author() author.author_type = self.parse_type(row['Risk']) if author.author_type == -1: return None author.author_full_name = unicode(row['AKA Name']).encode('ascii', 'ignore').decode('ascii') author.location = unicode(row['City'] + ' ' + row['Address']) author.geo_enabled = unicode(row['Location']) author.name=row['DBA Name'] author.created_at = unicode(row['Inspection Date']) return author except: return None
def parse_row(self, row): try: author = Author() author.author_type = self.parse_type(row['risk_category']) if author.author_type == -1: return None author.author_full_name = unicode(row['business_name']).encode('ascii', 'ignore').decode('ascii') author.name = unicode(author.author_full_name).encode('ascii', 'ignore').decode('ascii') author.location = unicode(row['business_city'] + ' ' + row['business_address']) author.geo_enabled = unicode(row['business_location']) if author.geo_enabled is None or author.geo_enabled == "": return None author.created_at = unicode(row['inspection_date']) return author except: logging.info("error with row:"+ str(row)) return None
def updateAuthorsData(self): list_to_add = [] for dic in self._author_prop_dict: try: author = Author() author.name = dic['author'] author.domain = unicode('Microblog') author.author_osn_id = dic['author_osn_id'] author.author_guid = dic['author_guid'] author.followers_count = dic['followers_count'] author.location = dic['location'] author.favourites_count = dic['favorite'] author.description = dic['description'] author.url = dic['url'] list_to_add.append(author) except (ValueError, TypeError, KeyError) as e: logging.warn("Failed to add author: {0} - {1}".format(author.name, e)) self._db.update_authors(list_to_add)