def json_tweet_object_to_Communication(tweet): """ """ tweet_info = json_tweet_object_to_TweetInfo(tweet) augf = AnalyticUUIDGeneratorFactory() aug = augf.create() if 'id_str' in tweet: tweet_id = tweet['id_str'] else: logging.warning('Tweet has no id_str, leaving communication id blank') tweet_id = None tweet_time = datetime_to_timestamp(datetime.strptime(tweet_info.createdAt, CREATED_AT_FORMAT)) comm = Communication( communicationMetadata=CommunicationMetadata( tweetInfo=tweet_info), metadata=AnnotationMetadata( tool=TOOL_NAME, timestamp=int(time.time())), originalText=tweet_info.text, text=tweet_info.text, type=TWEET_TYPE, uuid=aug.next(), startTime=tweet_time, endTime=tweet_time, id=tweet_id ) # either this, or pass in gen as parameter to fx # latter is more annoying to test but slightly cleaner if tweet_info.lid is not None: tweet_info.lid.uuid = aug.next() lidList = [tweet_info.lid] comm.lidList = lidList return comm