예제 #1
0
파일: lint.py 프로젝트: ondrocks/Framework
 def report_evaluation(self, sect, stats, old_stats):
     """make the global evaluation report"""
     # check with at least check 1 statements (usually 0 when there is a
     # syntax error preventing pylint from further processing)
     if stats['statement'] == 0:
         raise EmptyReport()
     # get a global note for the code
     evaluation = self.config.evaluation
     try:
         note = eval(evaluation, {}, self.stats)
     except Exception as ex:
         msg = 'An exception occurred while rating: %s' % ex
     else:
         stats['global_note'] = note
         msg = 'Your code has been rated at %.2f/10' % note
         if 'global_note' in old_stats:
             msg += ' (previous run: %.2f/10)' % old_stats['global_note']
         if self.config.comment:
             msg = '%s\n%s' % (msg, config.get_note_message(note))
     sect.append(Text(msg))
예제 #2
0
파일: lint.py 프로젝트: MaraKovalcik/Flask
        # get a global note for the code
        evaluation = self.config.evaluation
        try:
            note = eval(evaluation, {}, self.stats)
        except Exception, ex:
            msg = 'An exception occurred while rating: %s' % ex
        else:
            stats['global_note'] = note
            msg = 'Your code has been rated at %.2f/10' % note
            pnote = previous_stats.get('global_note')
            if pnote is not None:
                msg += ' (previous run: %.2f/10, %+.2f)' % (pnote,
                                                            note - pnote)
            if self.config.comment:
                msg = '%s\n%s' % (msg, config.get_note_message(note))
        sect.append(Text(msg))


# some reporting functions ####################################################


def report_total_messages_stats(sect, stats, previous_stats):
    """make total errors / warnings report"""
    lines = ['type', 'number', 'previous', 'difference']
    lines += table_lines_from_stats(
        stats, previous_stats, ('convention', 'refactor', 'warning', 'error'))
    sect.append(Table(children=lines, cols=4, rheaders=1))


def report_messages_stats(sect, stats, _):
    """make messages type report"""
예제 #3
0
 def format_eschema(self, eschema):
     text = eschema.type
     if self.req is None:
         return Text(text)
     return Link(self.req.build_url('cwetype/%s' % eschema), text)
예제 #4
0
 def format_rschema(self, rschema, label=None):
     if label is None:
         label = rschema.type
     if self.req is None:
         return Text(label)
     return Link(self.req.build_url('cwrtype/%s' % rschema), label)
예제 #5
0
    def visit_relationschema(self, rschema, title=True):
        """get a layout for a relation schema"""
        _ = self._
        if title:
            title = self.format_rschema(rschema)
            stereotypes = []
            if rschema.meta:
                stereotypes.append('meta')
            if rschema.symmetric:
                stereotypes.append('symmetric')
            if rschema.inlined:
                stereotypes.append('inlined')
            title = Section(children=(title, ), klass='title')
            if stereotypes:
                title.append(self.stereotype(','.join(stereotypes)))
            layout = Section(children=(title, ), klass='schema')
        else:
            layout = Section(klass='schema')
        data = [_('from'), _('to')]
        schema = rschema.schema
        rschema_objects = rschema.objects()
        if rschema_objects:
            # might be empty
            properties = [
                p for p in RelationDefinitionSchema.rproperty_defs(
                    rschema_objects[0])
                if p not in ('cardinality', 'composite', 'eid')
            ]
        else:
            properties = []
        data += [_(prop) for prop in properties]
        cols = len(data)
        done = set()
        for subjtype, objtypes in sorted(rschema.associations()):
            for objtype in objtypes:
                if (subjtype, objtype) in done:
                    continue
                done.add((subjtype, objtype))
                if rschema.symmetric:
                    done.add((objtype, subjtype))
                data.append(self.format_eschema(schema[subjtype]))
                data.append(self.format_eschema(schema[objtype]))
                rdef = rschema.rdef(subjtype, objtype)
                for prop in properties:
                    val = getattr(rdef, prop)
                    if val is None:
                        val = ''
                    elif prop == 'constraints':
                        val = ', '.join([c.expression for c in val])
                    elif isinstance(val, dict):
                        for key, value in val.items():
                            if isinstance(value, (list, tuple)):
                                val[key] = ', '.join(
                                    sorted(str(v) for v in value))
                        val = str(val)

                    elif isinstance(val, (list, tuple)):
                        val = sorted(val)
                        val = ', '.join(str(v) for v in val)
                    elif val and isinstance(val, str):
                        val = _(val)
                    else:
                        val = str(val)
                    data.append(Text(val))
        table = Table(cols=cols, rheaders=1, children=data, klass='listing')
        layout.append(Section(children=(table, ), klass='relationDefinition'))
        layout.append(Section(children='', klass='clear'))
        return layout