1. Rami Al-Rfou
  2. fastavro

Commits

Rami Al-Rfou  committed 25e0fde Draft Merge

Merged tebeka/fastavro into default

  • Participants
  • Parent commits 4e693d7, 3f1777c
  • Branches default

Comments (0)

Files changed (6)

File .hgtags

View file
  • Ignore whitespace
 e2703fb77fb6e79413d27e7fb2b02477eed161ae 0.7.0
 ca548b5a2557e8e9274015a8889e0c0cd8bf7932 0.7.1
 573652edc483173d3922fd3ddb5c6e17747729a4 0.7.2
+5c04fd4a152db9df1063675615b078540837e149 0.7.3
+9acd412bb23bea3eec307ae81d20219e2ef961ad 0.7.4
+9acd412bb23bea3eec307ae81d20219e2ef961ad 0.7.4
+c1d8d32f94a952dd478d3e00d72867faf858a98d 0.7.4

File ChangeLog

View file
  • Ignore whitespace
+2013-03-01 version 0.7.4
+    * Fixed regression in 2.7 and recursive
+
+2013-02-19 version 0.7.3
+    * Fixed bug in Python 3 printing
+
 2012-12-10 version 0.7.2
     * Fixed bug in argument parsing
 

File fastavro/__init__.py

View file
  • Ignore whitespace
 '''
 
 __all__ = [ 'iter_avro', 'reader']
-__version__ = '0.7.2'
+__version__ = '0.7.4'
 
 
 try:

File fastavro/__main__.py

View file
  • Ignore whitespace
 import fastavro as avro
+from fastavro.six import json_dump
 import json
 from sys import stdout
 
                         action='store_true', default=False)
     parser.add_argument('--version', action='version',
             version='fastavro {0}'.format(avro.__version__))
+    parser.add_argument('-p', '--pretty', help='pretty print json',
+                        action='store_true', default=False)
     args = parser.parse_args(argv[1:])
 
     if args.codecs:
         except ValueError as e:
             raise SystemExit('error: {0}'.format(e))
 
+
+
         if args.schema:
-            json.dump(reader.schema, stdout, indent=4, encoding=encoding)
+            json_dump(reader.schema)
             sys.stdout.write('\n')
             continue
 
+        indent = 4 if args.pretty else None
         try:
             for record in reader:
-                json.dump(record, stdout, encoding=encoding)
+                json_dump(record, indent)
                 sys.stdout.write('\n')
         except (IOError, KeyboardInterrupt):
             pass

File fastavro/six.py

View file
  • Ignore whitespace
 Some of this code is "lifted" from CherryPy.
 '''
 import sys
+import json
+from sys import stdout
 
 _encoding = 'UTF-8'
 
     def py3_utob(n, encoding=_encoding):
         return bytes(n, encoding)
 
+    def json_dump(obj, indent):
+        json.dump(obj, stdout, indent=indent)
+
 else:  # Python 2x
     from cStringIO import StringIO as MemoryIO
     xrange = xrange
     def py2_utob(n, encoding=_encoding):
         return n.encode(encoding)
 
+    _outenc = getattr(stdout, 'encoding', _encoding)
+    def json_dump(obj, indent):
+        json.dump(obj, stdout, indent=indent, encoding=_outenc)
+
 # We do it this way and not just redifine function since Cython do not like it
 if sys.version_info >= (3, 0):
     btou = py3_btou

File publish.sh

View file
  • Ignore whitespace
 
 make
 python setup.py bdist_egg upload
-python3 setup.py bdist_egg upload
-python3.3 setup.py bdist_egg upload
+python2 setup.py bdist_egg upload
 python setup.py sdist upload
 rm -fr build dist
 hg tag -f $(python setup.py --version)