<div dir="ltr">Hello Laurent,<div><br></div><div>you wrote:<br><div><br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> I think Redbaron might be much better suited to achieve that, it seems.<br>
<br>
</span>Yep, this is totally an use case for it. Actually you can go a level<br>
lower and directly do that with baron by writing a custom "dumper".<br></blockquote><div><br></div><div>Before reading this, I already managed to pretty much immediately get</div><div>this to work. I checked your pointers now, and I think they wouldn't do</div><div>what I want to do, because I don't want to change layout, and when I</div><div>want, I would be highly context sensitive.</div><div><br></div><div>f(</div><div>  a  = 1</div><div>  bb = 2</div><div>)</div><div><br></div><div>and</div><div><br></div><div>f(a = 1, bb = 2)</div><div><br></div><div>are both OK to me. But in one case, always one space is used, and in</div><div>other cases, vertical alignment is done.</div><div><br></div><div>Many more things, where I would be context sensitive. I like e.g. contractions</div><div>to be written like this:</div><div><br></div><div>a = [</div><div>  some_operation(a)</div><div>  for a in</div><div>  range(b)</div><div>  if a != 2</div><div>]</div><div><br></div><div>unless in cases where I don't do it, typically because there is no merit to</div><div>reviewing it.</div><div><br></div><div>So, I am more like patching, or at least detecting cases where the existing</div><div>white space layout is inconsistent.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<span class="">> Performance might be a red herring there, but xpath queries that make me<br>
> avoid touching nodes already properly formatted, would probably also be<br>
> faster. Most likely performance is not an issue at all. But xpath can be<br>
> run time compiled in principle.<br>
><br>
> Let me know what you think of that.<br>
<br>
</span>Since Baron (the AST) is lossless, as long as you do a lossless<br>
convertion between Baron and anything else you can do wathever you<br>
want. I actually wanted to do that with xml (as a "joke" to be honest<br>
with you, I don't have a very good appreciation of xml while I<br>
understand the power of some of its tools) to demonstration this<br>
property, I was not expecting people to actually request it.<br></blockquote><div><br></div><div>I appreciate the power of the xpath query language. It's really good at</div><div>saying find me nodes with attributes of that kind, and children with</div><div>attributes of another kind, and in a certain range.</div><div><br></div><div>It doesn't technically have to written as XML ever. But as a query API</div><div>it's fantastic. I have employed it with decoded binary data that systems</div><div>output, even wireshark captures, and with internal data recorded.</div><div><br></div><div>Given a good tree, that's the thing to have for me. It's much like what</div><div>SQL is to databases. A standard for querying.</div><div><br></div><div>I am not an XML fanboy otherwise. :-)</div><div><br></div><div> * I will eventually do it (a baron <-> xml convertor lib), but this</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  isn't very high in my todolist<br></blockquote><div><br></div><div>This is mainly an idea for you. I am OK with working with the Python</div><div>based API. I am mailing you with strangeness as I encountered it,</div><div>but it's absolutely workable, and for a Python programmer, not a big</div><div>deal.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
* as a practical solution, you will end up with a very low level data<br>
  structure (just like baron) especially for modifications. Basically,<br>
  you will face every low level details that I have abstracted for you<br>
  in RedBaron. If you want to follow this path, I really recommend you<br>
  to read RedBaron documentation first before doing so to evaluate if<br>
  the price to pay is worth it.<br></blockquote><div><br></div><div>I am not sure, why the XML tree would be all that different from what</div><div>"node.help()" does. Surely the first, second, third, etc. formatting will</div><div>simply become children, few people will look at.</div><div><br></div><div>Yours,</div><div>Kay</div><div> </div></div></div></div></div>