pretty-print

Pretty-print types and class template along with all its template arguments

不想你离开。 提交于 2019-11-27 16:13:49
问题 Since typeid(T).name() doesn't return human understandable name of the type, it doesn't help us much if we want to print the name of the template arguments to some class template, especially when we're debugging. We often feel like writing this in debugging: print<Args...>(cout); //dump the names of all types to stdout! So I'm writing pretty-print utility which gives me the name of the class template. Well, it is easier to understand it through some sample usage: print<int>(cout); //prints

Best way to pretty print XML response in grails

梦想与她 提交于 2019-11-27 14:58:00
问题 Given this in a grails action: def xml = { rss(version: '2.0') { ... } } render(contentType: 'application/rss+xml', xml) I see this: <rss><channel><title></title><description></description><link></link><item></item></channel></rss> Is there an easy way to pretty print the XML? Something built into the render method, perhaps? 回答1: According to the reference docs, you can use the following configuration option to enable pretty printing: grails.converters.default.pretty.print (Boolean) //Whether

Javascript console.log(object) vs. concatenating string

孤者浪人 提交于 2019-11-27 13:53:12
I'm running this in node.js: > x = { 'foo' : 'bar' } { foo: 'bar' } > console.log(x) { foo: 'bar' } undefined > console.log("hmm: " + x) hmm: [object Object] undefined What I don't understand is why console.log(x) "pretty-prints" the object, whereas string concatenation "ugly-prints" it. And more importantly, what's the best way to make it print hmm: { foo: 'bar' } ? The + x coerces the object x into a string, which is just [object Object] : http://jsfiddle.net/Ze32g/ The pretty printing is a very nice and probably very complex underlying code that someone implemented as part of the console

Python pretty XML printer with lxml

时光怂恿深爱的人放手 提交于 2019-11-27 12:27:29
After reading from an existing file with 'ugly' XML and doing some modifications, pretty printing doesn't work. I've tried etree.write(FILE_NAME, pretty_print=True) . I have the following XML: <testsuites tests="14" failures="0" disabled="0" errors="0" time="0.306" name="AllTests"> <testsuite name="AIR" tests="14" failures="0" disabled="0" errors="0" time="0.306"> .... And I use it like this: tree = etree.parse('original.xml') root = tree.getroot() ... # modifications ... with open(FILE_NAME, "w") as f: tree.write(f, pretty_print=True) For me, this issue was not solved until I noticed this

Is there a PowerShell code formatter / pretty printer? [closed]

点点圈 提交于 2019-11-27 10:44:32
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I'm looking for a source code beautifyer for PowerShell programs. Ideally, it would be CLI based, but any solution is acceptable. I would like to avoid configuring a generic pretty printer tool; I'd like a solution that works for PowerShell out of the box. Is there such a thing? 回答1: UPDATE: it's now on GitHub:

JSON.stringify output to div in pretty print way

半腔热情 提交于 2019-11-27 10:38:02
I JSON.stringify a json object by result = JSON.stringify(message, my_json, 2) The 2 in the argument above is supposed to pretty print the result. It does this if i do something like alert(result) . However, I want to output this to the user by appending it inside a div. When I do this I get just a single line showing up. (I don't think it is working because the breaks and spaces are not being interpreted as html?) { "data": { "x": "1", "y": "1", "url": "http://url.com" }, "event": "start", "show": 1, "id": 50 } Is there a way to output the result of JSON.stringify to a div in a pretty print

How can I pretty-print XML source using VB6 and MSXML?

久未见 提交于 2019-11-27 07:38:30
I've been looking after this for months now and I mostly found sites asking the same question. The answers I did found were always for .NET or C++ or involved XSLT. Daniel Rikowski After months of research I've come up with this. Public Function PrettyPrintXML(XML As String) As String Dim Reader As New SAXXMLReader60 Dim Writer As New MXXMLWriter60 Writer.indent = True Writer.standalone = False Writer.omitXMLDeclaration = False Writer.encoding = "utf-8" Set Reader.contentHandler = Writer Set Reader.dtdHandler = Writer Set Reader.errorHandler = Writer Call Reader.putProperty("http://xml.org/sax

Changing how output is printed to the console

淺唱寂寞╮ 提交于 2019-11-27 06:55:08
问题 When I print something directly to the console (type some variable name, such as x , rather than using the print function print(x) ), I'd like it to print differently from the way that it normally prints. My idea is that the printing is done by some function. If that's the case, all I have to do is replace that function with a function of my own. However, I cannot figure out what the internal function that does the printing is. Here is what I've tried so far. .real_cat = cat cat = function(x)

pretty printing numpy ndarrays using unicode characters

心已入冬 提交于 2019-11-27 06:16:06
问题 I have recently noticed that Python printing functionality is not consistent for NumPy ndarays. For example it prints a horizontal 1D array horizontally: import numpy as np A1=np.array([1,2,3]) print(A1) #--> [1 2 3] but a 1D horizontal array with redundant brackets vertically: A2=np.array([[1],[2],[3]]) print(A2) #--> [[1] # [2] # [3]] a 1D vertical array horizontally: A3=np.array([[1,2,3]]) print(A3) #--> [[1 2 3]] and a 2D array: B=np.array([[11,12,13],[21,22,23],[31,32,32]]) print(B) # --

How to Pretty Print HTML to a file, with indentation

随声附和 提交于 2019-11-27 05:06:17
问题 I am using lxml.html to generate some HTML. I want to pretty print (with indentation) my final result into an html file. How do I do that? This is what I have tried and got till now (I am relatively new to Python and lxml) : import lxml.html as lh from lxml.html import builder as E sliderRoot=lh.Element("div", E.CLASS("scroll"), style="overflow-x: hidden; overflow-y: hidden;") scrollContainer=lh.Element("div", E.CLASS("scrollContainer"), style="width: 4340px;") sliderRoot.append