Beispiel #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)
Beispiel #2
0
    """)
        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("""
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
    """)
        outFile.write('</body>')
        outFile.write('</html>')