Ejemplo n.º 1
0
    def tabulate(self, tablefmt=None):
        out  = ""
        match_type = self.type
        print_headings = False
        if match_type in ['duplicate']:
            if self.mObjects:
                # out += "The following ACT records are diplicates"
                if self.sObjects:
                    print_headings = True
                    # out += " of the following WORDPRESS records"
            else:
                assert self.sObjects
                # out += "The following WORDPRESS records are duplicates"
        elif match_type in ['masterless', 'slavelaveless']:
            pass
            # out += "The following records do not exist in %s" % {'masterless':'ACT', 'slaveless':'WORDPRESS'}[match_type]
        # out += "\n"

        if self.mLen or self.sLen:
            gcs = self.gcs
            if gcs is not None and hasattr(gcs, 'container'):
                obj_container = gcs.container(indexer=(lambda x: x.identifier))
                # else:
                    # container = None
                    # if hasattr(gcs, 'container'):
                    #     container = gcs.container
                    # Registrar.registerError("could not create GCS %s, container: %s | %s" % (repr(gcs), repr(container), str(e)))
                    # obj_container = ObjList()
                # Registrar.registerMessage(
                #     "tabulating with container: %s because of gcs %s" \
                #     % (type(obj_container), gcs)
                # )
            else:
                obj_container = ObjList(indexer=(lambda x: x.identifier))
                # Registrar.registerMessage(
                #     "tabulating with container: %s because no gcs" \
                #     % (type(obj_container))
                # )
            if self.mObjects:
                mobjs = self.mObjects[:]
                if(print_headings):
                    heading = gcs({}, rowcount='M')
                    # heading = ImportObject({}, rowcount='M')
                    mobjs = [heading] + mobjs
                for mobj in mobjs :
                    obj_container.append(mobj)
            if self.sObjects:
                sobjs = self.sObjects[:]
                if(print_headings):
                    heading = gcs({}, rowcount='S')
                    # heading = ImportObject({}, rowcount='S')
                    sobjs = [heading] + sobjs
                for sobj in sobjs:
                    # pprint(sobj)
                    obj_container.append(sobj)
            out += obj_container.tabulate(tablefmt=tablefmt)
        else:
            out += 'EMPTY'
        # return SanitationUtils.coerceUnicode(out)
        return (out)
Ejemplo n.º 2
0
        outFile.write("""
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
    """)
        outFile.write('<body>')
        outFile.write('<div class="matching">')
        outFile.write('<h1>%s</h1>' % 'Dynamic Pricing Ruels Report')
        for rule in dynParser.taxos.values():
            rule['html'] = rule.toHTML()
            rule['_pricing_rule'] = rule.to_pricing_rule()

        # print '\n'.join(map(str , dynParser.taxos.values()))
        dynList = ObjList(dynParser.taxos.values() )

        writeSection(
            "Dynamic Pricing Rules",
            "all products and their dynaimc pricing rules",
            re.sub("<table>","<table class=\"table table-striped\">",
                dynList.tabulate(cols=OrderedDict([
                    ('html', {}),
                    ('_pricing_rule', {}),
                ]), tablefmt="html")
            ),
            length = len(dynList.objects)
        )

        outFile.write('</div>')
        outFile.write("""