Generates a PrettyTables from a string of HTML code which contains only a
    single <table>
177975
def from_html_one(html_code, **kwargs):
    

    tables = from_html(html_code, **kwargs)
    try:
        assert len(tables) == 1
    except AssertionError:
        raise Exception("More than one <table> in provided HTML code!  Use from_html instead.")
    return tables[0]
998465
def create_html(self):
        """"""

        html_table = ""
        columns = [panel.get_html_column() for panel in self.panels]
        trs = len(columns[0])
        html_table += os.linesep.join(
            [
                "<tr>{}</tr>".format("".join(["<td>{}</td>".format(columns[col][row]) for col in range(len(columns))]))
                for row in range(trs)
            ]
        )

        with open(self._html_fn, "w+") as f:
            css_src = textwrap.dedent(
                """\
					.main_table                       {border-collapse:collapse;margin-top:15px;}
					td                                {border: solid #aaaaff 1px;padding:4px;vertical-alignment:top;}
					colgroup, thead                   {border: solid black 2px;padding 2px;}
					.configuration                    {font-size:85%;}
					.configuration, .configuration *  {margin:0;padding:0;}
					.formats                          {text-align:center;margin:20px 0px;}
					img                               {min-width:640px}
			"""
            )

            html_src = """<!DOCTYPE html>
			<html>
			<head>
				<meta charset="UTF-8" />
				<title>{title}</title>
				<style type="text/css">
				{css}
				</style>
			</head>
			<body>
				<h1>{title}</h1>
				<strong>{description}</strong>

				<table class="main_table">
				{html_table}
				</table>

			</body>
			""".format(
                html_table=html_table,
                css=css_src,
                title=self.title,
                description=self.description,
            )

            tidy_html_src = bs4.BeautifulSoup(html_src).prettify()
            f.write(tidy_html_src)
92364
function pretty(srcObj) {
      return typeOf(srcObj, 'arr', 'obj') ? JSON.stringify(srcObj, null, 2) : String(srcObj);
    }
284938
def pretty_format(obj, indent=None):
        
        if indent is None:
            if isinstance(obj, TLObject):
                obj = obj.to_dict()

            if isinstance(obj, dict):
                return '{}({})'.format(obj.get('_', 'dict'), ', '.join(
                    '{}={}'.format(k, TLObject.pretty_format(v))
                    for k, v in obj.items() if k != '_'
                ))
            elif isinstance(obj, str) or isinstance(obj, bytes):
                return repr(obj)
            elif hasattr(obj, '__iter__'):
                return '[{}]'.format(
                    ', '.join(TLObject.pretty_format(x) for x in obj)
                )
            else:
                return repr(obj)
        else:
            result = []
            if isinstance(obj, TLObject):
                obj = obj.to_dict()

            if isinstance(obj, dict):
                result.append(obj.get('_', 'dict'))
                result.append('(')
                if obj:
                    result.append('\n')
                    indent += 1
                    for k, v in obj.items():
                        if k == '_':
                            continue
                        result.append('\t' * indent)
                        result.append(k)
                        result.append('=')
                        result.append(TLObject.pretty_format(v, indent))
                        result.append(',\n')
                    result.pop()  # last ',\n'
                    indent -= 1
                    result.append('\n')
                    result.append('\t' * indent)
                result.append(')')

            elif isinstance(obj, str) or isinstance(obj, bytes):
                result.append(repr(obj))

            elif hasattr(obj, '__iter__'):
                result.append('[\n')
                indent += 1
                for x in obj:
                    result.append('\t' * indent)
                    result.append(TLObject.pretty_format(x, indent))
                    result.append(',\n')
                indent -= 1
                result.append('\t' * indent)
                result.append(']')

            else:
                result.append(repr(obj))

            return ''.join(result)
800432
private static String definitionListToHtml( DefinitionList dl){
		if( dl == null ) {
			return "null";
		}

		StringBuilder result = new StringBuilder();

		result.append("<table class=\"DefinitionList\">\n" +
				"<tr><th class=\"DefinitionList\">DefinitionList</th></tr>\n"+
				"<tr><td class=\"DefinitionList\">" );

		if( dl.getDefinedTerm() != null ) {
			result.append( contentElementToHtml( dl.getDefinedTerm() )+ "\n");
		}

		result.append("<ul>");
		for( ContentElement ce: dl.getDefinitions() ) {
			result.append("<li>"+contentElementToHtml(ce)+"</li>" );
		}

		result.append("</ul>\n");
		result.append("</td></tr>\n" );
		result.append("</table>\n");

		return result.toString();
	}
1339573
def generateSummaryHTMLTable(self, extraLapse = TYPICAL_LAPSE):
		''' 
		'''
		scriptsRun = self.scriptsRun
		
		html = []
		html.append("<table style='text-align:center;border:1px solid black;margin-left: auto;margin-right: auto;'>\n") # Start summary table
		html.append('	<tr><td colspan="4" style="text-align:center"></td></tr>\n')
		html.append('	<tr style="font-weight:bold;background-color:#cccccc;text-align:center"><td>Script</td><td>Last status</td><td>Last run</td><td>Last success</td></tr>\n')
		
		# Alternate shades between rows
		tablestyle = ['background-color:#33dd33;', 'background-color:#33ff33;']
		warningstyle = ['background-color:#EA8737;', 'background-color:#f5b767;']
		failstyle = ['background-color:#dd3333;', 'background-color:#ff3333;']
		
		count = 0
		for name, details in sorted(scriptsRun.iteritems()):
			status = None
			
			rowstyle = tablestyle[count % 2]
			if details["lastSuccess"] and expectedScripts.get(name):
				if not expectedScripts.check(name, details["lastSuccess"], extraLapse): 
					status = "STOPPED"
			else:
				rowstyle = failstyle[count % 2]
				status = "FAIL"
				
			laststatusstyle = tablestyle[count % 2]
			if details["status"] & RETROSPECT_FAIL:
				laststatusstyle = failstyle[count % 2]
				status = "FAIL"
			elif status != "STOPPED" and details["status"] & RETROSPECT_WARNING:
				laststatusstyle = warningstyle[count % 2]
				status = "WARNINGS"
			elif status != "FAIL" and status != "STOPPED":
				status = "OK"
				
			# Start a row	
			html.append('<tr style="text-align:left;%s">\n' % rowstyle)
			
			# Script name field
			if status == "STOPPED":
				html.append('\t<td style="%s">%s</td>\n' % (failstyle[count % 2], name))
			else:
				html.append('\t<td style="%s">%s</td>' % (tablestyle[count % 2], name))
			
				
			# Last status field
			if details["lastRun"]:
				if status == "STOPPED":
					html.append('\t<td style="%s"><a href="#%s">%s</a></td>\n' % (failstyle[count % 2], self.createAnchorID(name, details["lastRun"]), status))
				else:
					html.append('\t<td style="%s"><a href="#%s">%s</a></td>\n' % (laststatusstyle, self.createAnchorID(name, details["lastRun"]), status))
			else:
				html.append('\t<td style="%s">%s</td>\n' % (laststatusstyle, status))
			
			# Last run field
			if details["lastRun"]:
				html.append('\t<td style="%s"><a href="#%s">%s</a></td>\n' % (laststatusstyle, self.createAnchorID(name, details["lastRun"]), details["lastRun"]))
			else:
				html.append('\t<td style="%s">none found</td>\n' % laststatusstyle)
			
			# Last success field
			if details["lastSuccess"]:
				html.append('\t<td><a href="#%s">%s</a></td>\n' % (self.createAnchorID(name, details["lastSuccess"]), details["lastSuccess"]))
			else:
				html.append('\t<td>none found</td>\n')
			html.append('</tr>\n')
			count += 1
		html.append("</table>")
		return html
1158493
def to_html(data):
    
    base_html_template = Template('''
        <html>
            <head>
                {% if style %}
                <style type="text/css">
                    {{ style }}
                </style>
                {% endif %}
            </head>
            <body>
                {% if style %}
                    {{ body|safe }}
                {% else %}
                    <pre></code>{{ body }}</code></pre>
                {% endif %}
            </body>
        </html>
        ''')

    code = to_json(data, indent=4)
    if PYGMENTS_INSTALLED:
        c = Context({
            'body': highlight(code, JSONLexer(), HtmlFormatter()),
            'style': HtmlFormatter().get_style_defs('.highlight')
        })
        html = base_html_template.render(c)
    else:
        c = Context({'body': code})
        html = base_html_template.render(c)
    return html
169504
private List<List<String>> decodeTables(String[] tablesThatMustBeEmpty) {
        List<List<String>> answer = new ArrayList<>();
        for (String tableSet : tablesThatMustBeEmpty) {
            String tableNames[] = tableSet.split("\\+");
            answer.add(Arrays.asList(tableNames));
        }
        return answer;
    }
808688
def prettifysql(sql):
    """"""
    pretty = []
    for line in sql.split('\n'):
        pretty.extend(["%s,\n" % x for x in line.split(',')])
    return pretty
1329015
def __dumptable(self, table):
        
        for x in table.table.keys():
            sys.stdout.write("{0}\t<--- {1} {2}".format(x, table[x], type(table[x])))
            if isinstance(table[x], ID):
                sys.stdout(" {0}".format(table[x].value)),
            sys.stdout.write("\n")
755009
def make_html(self):
        
        html = None
        if self.function == 'total':
            html = u'<table border="0" width="100%" rules="cols" cellpadding="2">\n'\
                   '<tr><th colspan="2" align="left"><h3><font color="{1}">'\
                   '{0}</font></h3></th></tr>\n'\
                   .format(htmlsafe(self.title.strip()), self.color)

            for res in self.results:
                html = u'{0}<tr><td valign="top" align="right">{1}</td>'\
                       '<td valign="top" width="90%">{2}</td></tr>'\
                       .format(html, res[0], res[1])

        elif self.function == 'top':
            html = u'<table border="0" width="100%" rules="cols" cellpadding="2">\n'\
                   '<tr><th colspan="2" align="left"><h3><font color="{1}">'\
                   '{0}</font></h3></th></tr>\n'\
                   .format(htmlsafe(self.title.strip()), self.color)

            if self.results[0] is not None:
                for res in self.results:
                    if res is not None:
                        html = u'{0}<tr><td valign="top" align="right">{1}</td>'\
                               '<td valign="top" width="90%">{2}</td></tr>'\
                               .format(html, res[0], ', '.join(res[1]))
            else:
                html = u'{0}<tr><td valign="top" align="left">{1}</td>'\
                       .format(html, "None")
                
        elif self.function == 'table':
            html = u'<h3><font color="{1}">{0}</font></h3>'\
                   '<table width="100%" rules="cols" cellpadding="2">\n'\
                   '<tr bgcolor="#aaaaaa">'\
                   .format(htmlsafe(self.title.strip()), self.color)
            
            headers = re.split('\s*,\s*', self.headers)
            for i in range(len(headers)):
                html = '{0}<th align="center" colspan="1">'\
                       '<font color="black">{1}</font></th>'\
                       .format(html, headers[i].strip('"'))

            html = u'{0}</tr>\n'.format(html)
            
            oddflag = False
            lastval = ""            
            for res in sorted(self.results, key=lambda x: x[0]):
                if lastval != res[0]:
                    oddflag = not oddflag
                    if oddflag:
                        html = u'{0}<tr bgcolor="#dddddd">'.format(html)
                    else:
                        html = u'{0}<tr>'.format(html)

                    html = u'{0}<td valign="top" width="15%">{1}</td>'\
                           .format(html, res[0])
                else:
                    if oddflag:
                        html = u'{0}<tr bgcolor="#dddddd">'.format(html)
                    else:
                        html = u'{0}<tr>'.format(html)

                    html = u'{0}<td valign="top" width="15%">&nbsp;</td>'.format(html)
                lastval = res[0]
                
                for i in range(1, len(headers)-1):
                    html = u'{0}<td valign="top" width="15%">{1}</td>'.format(html, res[i])
                lastcol = get_fmt_results(res[-1], limit=10, fmt=u'<font color="darkred">{0}</font>')

                if lastcol[-1].find(u" more skipped]") > -1:
                    html = u'{0}<td valign="top" width="{1}%">{2} {3}</td></tr>\n'\
                           .format(html, 100-15*(len(headers)-1),
                                   u', '.join(lastcol[:-1]), lastcol[-1])
                else:
                    html = u'{0}<td valign="top" width="{1}%">{2}</td></tr>\n'\
                           .format(html, 100-15*(len(headers)-1), u', '.join(lastcol))

        self.html = u'{0}</table>\n<p>\n'.format(html)
402366
def prettyhtml(value, autoescape=None):
	''
	value = html_cleaner(value)
	return escape(value) if autoescape\
		and not isinstance(value, SafeData) else mark_safe(value)
430502
private static String toHtmlTable(final List<OptionWithMetaInfo> options) {
		StringBuilder htmlTable = new StringBuilder();
		htmlTable.append("<table class=\"table table-bordered\">\n");
		htmlTable.append("    <thead>\n");
		htmlTable.append("        <tr>\n");
		htmlTable.append("            <th class=\"text-left\" style=\"width: 20%\">Key</th>\n");
		htmlTable.append("            <th class=\"text-left\" style=\"width: 15%\">Default</th>\n");
		htmlTable.append("            <th class=\"text-left\" style=\"width: 65%\">Description</th>\n");
		htmlTable.append("        </tr>\n");
		htmlTable.append("    </thead>\n");
		htmlTable.append("    <tbody>\n");

		for (OptionWithMetaInfo option : options) {
			htmlTable.append(toHtmlString(option));
		}

		htmlTable.append("    </tbody>\n");
		htmlTable.append("</table>\n");

		return htmlTable.toString();
	}
52422
def as_html(self, table_class='code-difftable', line_class='line',
                new_lineno_class='lineno old', old_lineno_class='lineno new',
                code_class='code'):
        
        def _link_to_if(condition, label, url):
            """
            Generates a link if condition is meet or just the label if not.
            """

            if condition:
                return '''<a href="%(url)s">%(label)s</a>''' % {'url': url,
                                                                'label': label}
            else:
                return label
        diff_lines = self.prepare()
        _html_empty = True
        _html = []
        _html.append('''<table class="%(table_class)s">\n''' \
                                            % {'table_class': table_class})
        for diff in diff_lines:
            for line in diff['chunks']:
                _html_empty = False
                for change in line:
                    _html.append('''<tr class="%(line_class)s %(action)s">\n''' \
                        % {'line_class': line_class,
                           'action': change['action']})
                    anchor_old_id = ''
                    anchor_new_id = ''
                    anchor_old = "%(filename)s_o%(oldline_no)s" % \
                                {'filename': self._safe_id(diff['filename']),
                                 'oldline_no': change['old_lineno']}
                    anchor_new = "%(filename)s_n%(oldline_no)s" % \
                                {'filename': self._safe_id(diff['filename']),
                                 'oldline_no': change['new_lineno']}
                    cond_old = change['old_lineno'] != '...' and \
                                                        change['old_lineno']
                    cond_new = change['new_lineno'] != '...' and \
                                                        change['new_lineno']
                    if cond_old:
                        anchor_old_id = 'id="%s"' % anchor_old
                    if cond_new:
                        anchor_new_id = 'id="%s"' % anchor_new
                    ###########################################################
                    # OLD LINE NUMBER
                    ###########################################################
                    _html.append('''\t<td %(a_id)s class="%(old_lineno_cls)s">''' \
                                    % {'a_id': anchor_old_id,
                                       'old_lineno_cls': old_lineno_class})

                    _html.append('''<pre>%(link)s</pre>''' \
                        % {'link':
                        _link_to_if(cond_old, change['old_lineno'], '#%s' \
                                                                % anchor_old)})
                    _html.append('''</td>\n''')
                    ###########################################################
                    # NEW LINE NUMBER
                    ###########################################################

                    _html.append('''\t<td %(a_id)s class="%(new_lineno_cls)s">''' \
                                    % {'a_id': anchor_new_id,
                                       'new_lineno_cls': new_lineno_class})

                    _html.append('''<pre>%(link)s</pre>''' \
                        % {'link':
                        _link_to_if(cond_new, change['new_lineno'], '#%s' \
                                                                % anchor_new)})
                    _html.append('''</td>\n''')
                    ###########################################################
                    # CODE
                    ###########################################################
                    _html.append('''\t<td class="%(code_class)s">''' \
                                                % {'code_class': code_class})
                    _html.append('''\n\t\t<pre>%(code)s</pre>\n''' \
                                                % {'code': change['line']})
                    _html.append('''\t</td>''')
                    _html.append('''\n</tr>\n''')
        _html.append('''</table>''')
        if _html_empty:
            return None
        return ''.join(_html)
1024222
function toPrintable(exclude, noColor) {
    var str = '{ ' + ( this._typeName ? 'T:' + this._typeName.bold : '');
    if (typeof exclude !== 'object') {
        noColor = exclude;
        exclude = {};
    }
    for (var prop in this) {
        if ('_' !== prop.charAt(0) && exclude[prop] !== true) {
            var pair = value2String(prop, this[prop], exclude[prop], noColor);
            if (pair.value !== undefined) {
                str = str.slice(-1) === ' ' ? str : str + ', ';
                str += (noColor ? pair.prop : pair.prop.bold.cyan) + ': ' + pair.value;
            }
        }
    }
    str += ' }';
    return str;
}
1175015
def to_html(threshold=50)
      html = "<html><table><tr><td></td>"
      html += @labels.map{|label| "<th>" + label.to_s +  "</th>"}.join
      html += "</tr>"
      self.each_row.with_index do |row, pos|
        next if pos > threshold && pos != self.length-1
        html += "<tr><th>" + @index[pos].to_s + "</th>"
        html += @labels.map{|label| "<td>" + row[label].to_s + "</td>"}.join
        html += "</tr>"
        html += "<tr><th>...</th>" + "<td>...</td>"*@labels.length + "</tr>" if pos == threshold
      end
      html += "</table>"
    end
872217
def _get_pretty_body(headers, body):
    

    if HEADER_CONTENT_TYPE in headers:
        if HEADER_REPRESENTATION_XML == headers[HEADER_CONTENT_TYPE]:
            xml_parsed = parseString(body)
            pretty_xml_as_string = xml_parsed.toprettyxml()
            return pretty_xml_as_string
        else:
            if HEADER_REPRESENTATION_JSON in headers[HEADER_CONTENT_TYPE]:
                parsed = json.loads(body)
                return json.dumps(parsed, sort_keys=True, indent=4)
            else:
                return body
    else:
        return body