def setUp(self): self.config = getConfig() self._db = DB() self._db.setUp() self.timeline_overlap = TimelineOverlapVisualizationGenerator() author1 = Author() author1.name = 'acquired_user' author1.domain = 'Microblog' author1.author_guid = 'acquired_user' author1.author_screen_name = 'acquired_user' author1.author_full_name = 'acquired_user' author1.author_osn_id = 1 author1.created_at = datetime.datetime.now() author1.missing_data_complementor_insertion_date = datetime.datetime.now( ) author1.xml_importer_insertion_date = datetime.datetime.now() author1.author_type = 'bad_actor' author1.author_sub_type = 'acquired' self._db.add_author(author1) for i in range(1, 11): post1 = Post() post1.post_id = 'bad_post' + str(i) post1.author = 'acquired_user' post1.guid = 'bad_post' + str(i) post1.date = datetime.datetime.now() post1.domain = 'Microblog' post1.author_guid = 'acquired_user' post1.content = 'InternetTV love it' + str(i) post1.xml_importer_insertion_date = datetime.datetime.now() self._db.addPost(post1) author = Author() author.name = 'TestUser1' author.domain = 'Microblog' author.author_guid = 'TestUser1' author.author_screen_name = 'TestUser1' author.author_full_name = 'TestUser1' author.author_osn_id = 2 author.created_at = datetime.datetime.now() author.missing_data_complementor_insertion_date = datetime.datetime.now( ) author.xml_importer_insertion_date = datetime.datetime.now() self._db.add_author(author) for i in range(1, 11): post = Post() post.post_id = 'TestPost' + str(i) post.author = 'TestUser1' post.guid = 'TestPost' + str(i) post.date = datetime.datetime.now() post.domain = 'Microblog' post.author_guid = 'TestUser1' post.content = 'InternetTV love it' + str(i) post.xml_importer_insertion_date = datetime.datetime.now() self._db.addPost(post) self._db.commit()
def _add_author(self, name=None, link_karma=None, comment_karma=None, is_employee=0, is_mod=0, is_gold=0, author_osn_id=None): author = Author() reddit_author = RedditAuthor() author.name = name author.author_screen_name = author.name author.author_guid = compute_author_guid_by_author_name(author.name) author.domain = 'reddit' author.author_osn_id = author_osn_id author.author_full_name = name author.url = 'https://www.reddit.com/user/' + name reddit_author.name = author.name reddit_author.author_guid = author.author_guid reddit_author.comments_count = None reddit_author.comment_karma = comment_karma reddit_author.link_karma = link_karma reddit_author.is_gold = is_gold reddit_author.is_moderator = is_mod reddit_author.is_employee = is_employee self._db.add_authors([author]) self._db.add_reddit_authors([reddit_author])
def _set_author(self, author_guid): author = Author() author.author_guid = author_guid author.author_full_name = u'name' + author_guid author.name = u'name' + author_guid author.domain = u'test' self._db.add_author(author) self._author = author
def extract_author(self, data): author = Author() author.name = str(data['source']) author.domain = 'BuzzFeed' author.author_guid = compute_author_guid_by_author_name(data['source']) author.author_screen_name = author.name author.author_full_name = author.name return author
def _add_author(self, author_guid): author = Author() author.author_guid = author_guid author.author_full_name = u'test author' author.name = u'test' author.domain = u'test' self._db.add_author(author) self._db.session.commit() self._authors.append(author)
def _add_author(self, author_guid): author = Author() author.author_guid = author_guid author.author_full_name = u'test author' author.name = u'test' author.domain = u'tests' author.statuses_count = 0 self._db.add_author(author) self._author = author
def _add_author(self, author_guid, type=u"good_actor"): author = Author() author.author_guid = author_guid author.author_full_name = author_guid author.author_screen_name = author_guid author.name = author_guid author.domain = u'Microblog' author.author_type = type self._db.add_author(author) self._authors.append(author)
def liker_to_author(self, liker, photo_id): author = Author() author.name = str(liker['username']) author.author_full_name = str(liker.get('realname', "")) author.domain = str(photo_id) author.created_at = str(liker["favedate"]) author.author_osn_id = str(liker['nsid']) author.author_guid = compute_author_guid_by_author_name( author.author_osn_id) author.author_type = 'like' return author
def _add_author(self, author_guid): author = Author() author.author_guid = author_guid author.author_full_name = u'test author' author.author_screen_name = author_guid author.name = u'test' author.domain = u'tests' author.statuses_count = 0 author.created_at = u"2017-06-14 05:00:00" # self._db.add_author(author) self._author = author
def _convert_reddit_author_to_author(self, redditor): author = Author() author.name = getattr(redditor, 'name', '') author.author_screen_name = author.name author.author_guid = compute_author_guid_by_author_name(author.name) author.domain = u'reddit' author.created_at = datetime.fromtimestamp(getattr(redditor, 'created_utc', 0)) author.author_osn_id = getattr(redditor, 'id', '') author.author_full_name = getattr(redditor, 'fullname', '') author.url = u'https://www.reddit.com/user/' + redditor.name return author
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 commenter_to_author(self, commenter, photo_id): author = Author() author.name = str(commenter['authorname']) author.author_screen_name = str(commenter['path_alias']) author.author_full_name = str(commenter.get('realname', "")) author.url = str(commenter['permalink']) author.domain = str(photo_id) author.created_at = str(commenter["datecreate"]) author.author_osn_id = str(commenter['author']) author.author_guid = compute_author_guid_by_author_name( author.author_osn_id) author.author_type = 'comment' return author
def _json_user_to_db_author_converter(self, user, domain='Instagram_author'): author = Author() author.name = user['username'] author.author_screen_name = author.name author.author_guid = compute_author_guid_by_author_name(author.name) author.domain = domain author.author_type = domain author.author_osn_id = user['id'] author.author_full_name = user['full_name'] author.description = user.setdefault('biography', None) author.url = 'https://www.instagram.com/' + author.author_screen_name author.profile_image_url = user['profile_pic_url'] 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 setUp(self): self._db = DB() self._db.setUp() self.author_guid = u"author_guid" author = Author() author.author_guid = self.author_guid author.author_full_name = u'author' author.name = u'author_name' author.author_screen_name = u'author_screen_name' author.domain = u'Microblog' author.statuses_count = 10 author.friends_count = 5 author.followers_count = 6 author.favourites_count = 8 author.author_sub_type = u"bot" author.author_type = u"bad" author.created_at = u"2017-06-17 05:00:00" author.default_profile = True author.default_profile_image = True author.verified = True self._db.add_author(author) post = Post() post.author = self.author_guid post.author_guid = self.author_guid post.content = u"content" post.title = u"title" post.domain = u"domain" post.post_id = u"post_id" post.guid = post.post_id post.date = convert_str_to_unicode_datetime("2017-06-14 05:00:00") post.created_at = post.date self._db.addPost(post) self._db.session.commit() self.feature_prefix = u"AccountPropertiesFeatureGenerator_" self.account_properties_feature_generator = AccountPropertiesFeatureGenerator( self._db, **{ 'authors': [author], 'posts': { self.author_guid: [post] } }) self.account_properties_feature_generator.execute()