Beispiel #1
0
    def get_or_create(cls, session, comment_id):
        comment_id = Util.plain_id(comment_id)
        comment = session.query(cls).filter(cls.reddit_id == comment_id).first()

        if (comment == None):
            comment = cls.create(session, comment_id)

        return comment
Beispiel #2
0
    def get_or_create(cls, session, post_id):
        post_id = Util.plain_id(post_id)
        post = session.query(cls).filter(cls.reddit_id == post_id).first()

        if (post == None):
            post = cls.create(session, post_id)

        return post
Beispiel #3
0
    def update_from_praw(self, p):
        self.reddit_id  = Util.plain_id(p.id)

        self.gilded = bool(p.gilded)
        self.edited = float(p.edited)

        self.body   = p.body
        self.ups    = p.ups
        self.downs  = p.downs

        self.created        = p.created
        self.created_utc    = p.created_utc
        self.scraped_time   = Util.now()
Beispiel #4
0
    def update_from_praw(self, p):
        self.header_img = p.header_img
        self.header_title = p.header_title
        self.title = p.title
        self.display_name = p.display_name

        self.name = p.name
        self.url = p.url.lower().strip()

        self.reddit_id = Util.plain_id(p.id)

        self.description = p.description
        self.description_html = p.description_html
        self.public_description = p.public_description

        self.created = p.created
        self.created_utc = p.created_utc
        self.scraped_time = Util.now()

        self.accounts_active = p.accounts_active
        self.subscribers = p.subscribers
        self.over18 = bool(p.over18)
Beispiel #5
0
    def create(cls, session, comment_id):
        comment = cls()
        comment.reddit_id = Util.plain_id(comment_id)

        Util.add_and_refresh(session, comment)
        return comment
Beispiel #6
0
    def create(cls, session, post_id):
        post = cls()
        post.reddit_id = Util.plain_id(post_id)

        Util.add_and_refresh(session, post)
        return post