def detail(name): try: id = int(name) except: id = 0 table = PluginTable() if id > 0: plugin = table.findById(id) else: plugin = table.findByName(name) if plugin: printPlugin(plugin) else: print "Sorry, we cannot find plugin %s for you" % name
def calc(self, id=0, data=None): table = PluginTable() table.connect() id = int(id) avg = self.calcAvg() if id > 0: data = table.findById(id) if data: score = self.gradePlugin(data, avg) table.updateScore(id, score) return score rows=table.query(None, None, 0) for row in rows: score = self.gradePlugin(row, avg) table.updateScore(row['id'], score) return len(rows)
def grade(name=None): grader = Grader() if not name: count = grader.calc() print "jobs done, scores of %d plugins updated" % count return try: id = int(name) except: id = 0 table = PluginTable() if id: plugin = table.findById(id) else: plugin = table.findByName(name) if plugin: grader.calc(data=plugin) else: print "Sorry, we cannot find plugin %s" % name