How to use the prettytable._compact.escape function in prettytable

To help you get started, we’ve selected a few prettytable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kxxoling / PTable / prettytable / prettytable.py View on Github external
# Data
        rows = self._get_rows(options)
        formatted_rows = self._format_rows(rows, options)
        aligns = []
        valigns = []
        for field in self._field_names:
            aligns.append({"l": "left", "r": "right", "c": "center"}[self._align[field]])
            valigns.append({"t": "top", "m": "middle", "b": "bottom"}[self._valign[field]])
        for row in formatted_rows:
            lines.append("    ")
            for field, datum, align, valign in zip(self._field_names, row, aligns, valigns):
                if options["fields"] and field not in options["fields"]:
                    continue
                lines.append(
                    "        %s" % (
                    lpad, rpad, align, valign, escape(datum).replace("\n", linebreak)))
            lines.append("    ")
        lines.append("")

        return self._unicode("\n").join(lines)
github kxxoling / PTable / prettytable / prettytable.py View on Github external
# Title
        title = options["title"] or self._title
        if title:
            cols = len(options["fields"]) if options["fields"] else len(self.field_names)
            lines.append("    ")
            lines.append("        %s" % (cols, title))
            lines.append("    ")

        # Headers
        if options["header"]:
            lines.append("    ")
            for field in self._field_names:
                if options["fields"] and field not in options["fields"]:
                    continue
                lines.append("        %s" % escape(field).replace("\n", linebreak))
            lines.append("    ")

        # Data
        rows = self._get_rows(options)
        formatted_rows = self._format_rows(rows, options)
        for row in formatted_rows:
            lines.append("    ")
            for field, datum in zip(self._field_names, row):
                if options["fields"] and field not in options["fields"]:
                    continue
                lines.append("        %s" % escape(datum).replace("\n", linebreak))
            lines.append("    ")

        lines.append("")

        return self._unicode("\n").join(lines)
github kxxoling / PTable / prettytable / prettytable.py View on Github external
title = options["title"] or self._title
        if title:
            cols = len(options["fields"]) if options["fields"] else len(self.field_names)
            lines.append("    ")
            lines.append("        %s" % (cols, title))
            lines.append("    ")

        # Headers
        if options["header"]:
            lines.append("    ")
            for field in self._field_names:
                if options["fields"] and field not in options["fields"]:
                    continue
                lines.append(
                    "        %s" % (
                    lpad, rpad, escape(field).replace("\n", linebreak)))
            lines.append("    ")

        # Data
        rows = self._get_rows(options)
        formatted_rows = self._format_rows(rows, options)
        aligns = []
        valigns = []
        for field in self._field_names:
            aligns.append({"l": "left", "r": "right", "c": "center"}[self._align[field]])
            valigns.append({"t": "top", "m": "middle", "b": "bottom"}[self._valign[field]])
        for row in formatted_rows:
            lines.append("    ")
            for field, datum, align, valign in zip(self._field_names, row, aligns, valigns):
                if options["fields"] and field not in options["fields"]:
                    continue
                lines.append(
github kxxoling / PTable / prettytable / prettytable.py View on Github external
lines.append("    ")
            for field in self._field_names:
                if options["fields"] and field not in options["fields"]:
                    continue
                lines.append("        %s" % escape(field).replace("\n", linebreak))
            lines.append("    ")

        # Data
        rows = self._get_rows(options)
        formatted_rows = self._format_rows(rows, options)
        for row in formatted_rows:
            lines.append("    ")
            for field, datum in zip(self._field_names, row):
                if options["fields"] and field not in options["fields"]:
                    continue
                lines.append("        %s" % escape(datum).replace("\n", linebreak))
            lines.append("    ")

        lines.append("")

        return self._unicode("\n").join(lines)