Пример #1
0
 def upitem(self, session, item, reason=None):
     """ up a karma item with/without reason """
     item = item.lower()
     karma = session.query(Karma).filter(Karma.item == item).first()
     if not karma:
         karma = Karma(item, 0)
         session.add(karma)
     karma.value = karma.value + 1
     if reason:
         whykarma = WhyKarma(item, 'up', reason.strip())
         session.save(whykarma)
Пример #2
0
 def upitem(self, session, item, reason=None):
     """ up a karma item with/without reason """
     item = item.lower()
     karma = session.query(Karma).filter(Karma.item==item).first()
     if not karma:
         karma = Karma(item, 0)
         session.add(karma)
     karma.value = karma.value + 1
     if reason:
         whykarma = WhyKarma(item, 'up', reason.strip())
         session.save(whykarma)
Пример #3
0
 def down(self, session, item, reason=None):
     """ lower a karma item with/without reason """
     item = item.lower()
     s = create_session()
     karma = s.query(Karma).filter(Karma.item == item).first()
     if not karma:
         karma = Karma(item, 0)
         session.add(karma)
     karma.value = karma.value - 1
     if reason:
         whykarma = WhyKarma(item, 'down', reason.strip())
         session.save(whykarma)
Пример #4
0
 def down(self, session, item, reason=None):
     """ lower a karma item with/without reason """
     item = item.lower()
     s = create_session()
     karma = s.query(Karma).filter(Karma.item==item).first()
     if not karma:
         karma = Karma(item, 0)
         session.add(karma)
     karma.value = karma.value - 1
     if reason:
         whykarma = WhyKarma(item, 'down', reason.strip())
         session.save(whykarma)
Пример #5
0
 def add(self, session, item, value):
     item = item.lower()
     karma = Karma(item, value)
     session.add(karma)
     session.commit()
     rlog(10, 'karma', 'added %s: %s' % (item, value))
     return 1
Пример #6
0
                        karma.setwhoup(i[0], i[1])
                    else:
                        karma.setwhodown(i[0], i[1])
            result = db.execute(""" SELECT * FROM whykarma """)
            if result:
                for i in result:
                    karma.addwhy(*i)
        except Exception, ex:
            handle_exception()
        return teller
    try:
        from gozerbot.utils.generic import dosed
        from gozerbot.database.db import Db
        from gozerbot.compat.karma import Karma
        #dosed(oldfile, 's/cgozerbot\.compat/cgozerplugs/')
        oldkarma = Karma(oldfile)
        if not oldkarma:
            return
        k = oldkarma
        for i, j in k.karma.iteritems():
            karma.add(i, j)
            teller += 1
        for i, j in k.reasonup.iteritems():
            for z in j:
                karma.addwhy(i, 'up', z)

        for i, j in k.reasondown.iteritems():
            for z in j:
                karma.addwhy(i, 'up', z)

        for i, j in k.whodown.iteritems():