Пример #1
0
    def _export_table(self,
                      export_sheet_name,
                      headers,
                      formatted_rows,
                      total_row=None):
        def _unformat_row(row):
            return [
                col.get("sort_key", col) if isinstance(col, dict) else col
                for col in row
            ]

        table = headers.as_export_table
        table.insert(0, [
            SQLLocation.objects.get(
                location_id=self.report_config['location_id']).name
        ])
        rows = [_unformat_row(row) for row in formatted_rows]
        # Removing html icon tag from MOS column
        for row in rows:
            row[1] = GenericTabularReport._strip_tags(row[1])
        replace = ''

        for k, v in enumerate(table[1]):
            if v != ' ':
                replace = v
            else:
                table[1][k] = replace
        table.extend(rows)
        if total_row:
            table.append(_unformat_row(total_row))

        return [export_sheet_name, self._report_info + table]
Пример #2
0
 def test_strip_tags_expected_fail(self):
     """
     _strip_tags should not strip strings inside angle brackets, but does
     """
     value = '1 < 8 > 2'
     value = GenericTabularReport._strip_tags(value)
     self.assertEqual(value, '1 < 8 > 2')
Пример #3
0
 def test_strip_tags_html_bytestring(self):
     """
     _strip_tags should strip HTML tags
     """
     value = '<blink>182</blink>'
     value = GenericTabularReport._strip_tags(value)
     self.assertEqual(value, '182')
Пример #4
0
 def test_strip_tags_html_unicode(self):
     """
     _strip_tags should strip HTML tags from Unicode
     """
     value = u'<blink>182</blink>'
     value = GenericTabularReport._strip_tags(value)
     self.assertEqual(value, u'182')
Пример #5
0
 def test_strip_tags_passthru(self):
     """
     _strip_tags should allow non-basestring values to pass through
     """
     value = {'blink': 182}
     value = GenericTabularReport._strip_tags(value)
     self.assertEqual(value, {'blink': 182})
Пример #6
0
 def test_strip_tags_expected_fail(self):
     """
     _strip_tags should not strip strings inside angle brackets, but does
     """
     value = '1 < 8 > 2'
     value = GenericTabularReport._strip_tags(value)
     self.assertEqual(value, '1 < 8 > 2')
Пример #7
0
    def _export_table(self,
                      export_sheet_name,
                      headers,
                      formatted_rows,
                      total_row=None):
        def _unformat_row(row):
            return [
                col.get("sort_key", col) if isinstance(col, dict) else col
                for col in row
            ]

        table = headers.as_export_table
        rows = [_unformat_row(row) for row in formatted_rows]
        replace = ''

        for row in rows:
            for index, value in enumerate(row):
                row[index] = GenericTabularReport._strip_tags(value)

        # make headers and subheaders consistent
        for k, v in enumerate(table[0]):
            if v != ' ':
                replace = v
            else:
                table[0][k] = replace
        table.extend(rows)
        if total_row:
            table.append(_unformat_row(total_row))

        return [export_sheet_name, table]
Пример #8
0
 def test_strip_tags_html_bytestring(self):
     """
     _strip_tags should strip HTML tags
     """
     value = '<blink>182</blink>'
     value = GenericTabularReport._strip_tags(value)
     self.assertEqual(value, '182')
Пример #9
0
 def test_strip_tags_passthru(self):
     """
     _strip_tags should allow non-basestring values to pass through
     """
     value = {'blink': 182}
     value = GenericTabularReport._strip_tags(value)
     self.assertEqual(value, {'blink': 182})
Пример #10
0
    def _export(self,
                export_sheet_name,
                headers,
                formatted_rows,
                total_row=None):
        def _unformat_row(row):
            return [
                col.get("sort_key", col) if isinstance(col, dict) else col
                for col in row
            ]

        table = headers.as_export_table
        rows = [_unformat_row(row) for row in formatted_rows]
        for row in rows:
            row[0] = GenericTabularReport._strip_tags(row[0])
        replace = ''

        for k, v in enumerate(table[0]):
            if v != ' ':
                replace = v
            else:
                table[0][k] = replace
        table.extend(rows)
        if total_row:
            table.append(_unformat_row(total_row))

        return [export_sheet_name, self._report_info + table]
Пример #11
0
 def test_strip_tags_html_unicode(self):
     """
     _strip_tags should strip HTML tags from Unicode
     """
     value = u'<blink>182</blink>'
     value = GenericTabularReport._strip_tags(value)
     self.assertEqual(value, u'182')
Пример #12
0
    def _export(self, export_sheet_name, headers, formatted_rows, total_row=None):
        def _unformat_row(row):
            return [col.get("sort_key", col) if isinstance(col, dict) else col for col in row]

        table = headers.as_export_table
        rows = [_unformat_row(row) for row in formatted_rows]
        for row in rows:
            row[0] = GenericTabularReport._strip_tags(row[0])
        replace = ''

        for k, v in enumerate(table[0]):
            if v != ' ':
                replace = v
            else:
                table[0][k] = replace
        table.extend(rows)

        return [export_sheet_name, self._report_info + table]
Пример #13
0
    def _export_table(self, export_sheet_name, headers, formatted_rows, total_row=None):
        def _unformat_row(row):
            return [col.get("sort_key", col) if isinstance(col, dict) else col for col in row]

        table = headers.as_export_table
        rows = [_unformat_row(row) for row in formatted_rows]
        # Removing html icon tag from MOS column
        for row in rows:
            row[1] = GenericTabularReport._strip_tags(row[1])
        replace = ''

        for k, v in enumerate(table[0]):
            if v != ' ':
                replace = v
            else:
                table[0][k] = replace
        table.extend(rows)
        if total_row:
            table.append(_unformat_row(total_row))

        return [export_sheet_name, table]
Пример #14
0
    def _export_table(self, export_sheet_name, headers, formatted_rows, total_row=None):
        def _unformat_row(row):
            return [col.get("sort_key", col) if isinstance(col, dict) else col for col in row]

        table = headers.as_export_table
        table.insert(0, [SQLLocation.objects.get(location_id=self.report_config['location_id']).name])
        rows = [_unformat_row(row) for row in formatted_rows]
        # Removing html icon tag from MOS column
        for row in rows:
            row[1] = GenericTabularReport._strip_tags(row[1])
        replace = ''

        for k, v in enumerate(table[1]):
            if v != ' ':
                replace = v
            else:
                table[1][k] = replace
        table.extend(rows)
        if total_row:
            table.append(_unformat_row(total_row))

        return [export_sheet_name, self._report_info + table]
Пример #15
0
    def _export_table(self, export_sheet_name, headers, formatted_rows, total_row=None):
        def _unformat_row(row):
            return [col.get("sort_key", col) if isinstance(col, dict) else col for col in row]

        table = headers.as_export_table
        rows = [_unformat_row(row) for row in formatted_rows]
        replace = ''

        for row in rows:
            for index, value in enumerate(row):
                row[index] = GenericTabularReport._strip_tags(value)

        # make headers and subheaders consistent
        for k, v in enumerate(table[0]):
            if v != ' ':
                replace = v
            else:
                table[0][k] = replace
        table.extend(rows)
        if total_row:
            table.append(_unformat_row(total_row))

        return [export_sheet_name, table]