def __init__(self, key, title, authors, year, institutions, valid=True): self.valid = valid self.key = key self.title = title self.insts = institutions self.authors = BaseConflicts(institutions) for author in authors: name, a_key = author self.authors.add_co_author(Person(name, a_key, key)) self.year = year
def add_co_author(self, a): if isinstance(a, ConflictSet): raise ValueError( "Trying to add a conflict list to a conflict list") if isinstance(a, BaseConflicts): raise ValueError( "Trying to add a conflict list to a conflict list") if isinstance(a, Person): p = a else: p = Person(a) self.collabs.add(p)
def index(): p = Person().query.filter(id=1).first().execute() result = p.one().id return str(result)
def fill_user_info(user_obj: Person): try: user_profile = Profile(user.name) """ show_name = StringProperty() biography = StringProperty() profile_photo = StringProperty() likes_count = IntegerProperty() tweets_count = IntegerProperty() followers_count = IntegerProperty() following_count = IntegerProperty() """ user_obj.show_name = user_profile.name user_obj.biography = user_profile.biography user_obj.profile_photo = user_profile.profile_photo user_obj.likes_count = user_profile.likes_count user_obj.tweets_count = user_profile.tweets_count user_obj.followers_count = user_profile.followers_count user_obj.following_count = user_profile.following_count user_obj.save() using_tags = user_profile.tags if using_tags: for tag in using_tags: tag_obj = HashTag.get_or_create(tag_name=tag) if not tag_obj: tag_obj = HashTag(tag_name=tag).save() user.using_tag.connect(tag_obj) print(user_profile.to_dict()) except Exception as e: print(e) user_obj.delete()
def connect_following(user, following_list): for following in following_list: following_user = Person.nodes.get_or_none(name=following[1:-1]) if not following_user: following_user = Person(name=following[1:-1]).save() user.following.connect(following_user)