[ 
https://issues.apache.org/jira/browse/AVRO-199?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12779846#action_12779846
 ] 

Philip Zeyliger commented on AVRO-199:
--------------------------------------

+1 to this patch.

As for the style issue, I prefer """, but I think you can do it with good 
indentation.  In this case, the indentation can be fixed:

{noformat}
[0]doorstop::rubicon(231418)$python foo.py

    This is pretty clearly part of
    the print statement.
  

And you can even do trickery
to get rid of the extra spacing.

[0]doorstop::rubicon(231419)$cat foo.py
import textwrap

def f():
  print """
    This is pretty clearly part of
    the print statement.
  """

  print textwrap.dedent("""
    And you can even do trickery
    to get rid of the extra spacing.
  """)

f()
{noformat}
You don't have to do the dedent trick here, because it's JSON.  Who cares if 
there's a lot of spacing!

If this code wasn't testing the schema stuff so explicitly, I'd say you could 
just use dict(), {}, and [] to specify the schema and convert to json using 
simplejson.

> Clean up schemas in testio.py
> -----------------------------
>
>                 Key: AVRO-199
>                 URL: https://issues.apache.org/jira/browse/AVRO-199
>             Project: Avro
>          Issue Type: Improvement
>          Components: python
>            Reporter: Jeff Hammerbacher
>            Assignee: Jeff Hammerbacher
>         Attachments: AVRO-199.patch, AVRO-199.patch
>
>
> As discussed on the mailing list, it would be nice to leverage Python's 
> expressive string syntax to not perform lots of escaping of Avro schemas 
> defined in code and make the schemas more readable.
> This patch cleans up schemas in testio.py to make them more readable. Note 
> that to get this to pass the tests, I had to implement a new 
> "remove_whitespace()" helper function to replace the current naive approach 
> to replacing whitespace (s.replace(" ", "") is not going to cut it). I also 
> object to the round-trip string conversion test, as noted in the comments to 
> this patch, but I'll save that change for another patch to better separate 
> concerns.
> If this code change is deemed useful, I'll convert the rest of the schemas in 
> the Python code to leverage Python's string formatting. I have a ridiculously 
> naive tool that I used for schema conversion that I threw up at 
> http://github.com/hammer/avro-tools/blob/master/pprint_avsc for those 
> interested.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to