Commits

Miki Tebeka committed 2725d11 Merge

0.7.7 - we should be OK now

  • Participants
  • Parent commits 785e228, a5bc2db

Comments (0)

Files changed (8)

 9acd412bb23bea3eec307ae81d20219e2ef961ad 0.7.4
 9acd412bb23bea3eec307ae81d20219e2ef961ad 0.7.4
 c1d8d32f94a952dd478d3e00d72867faf858a98d 0.7.4
+219e38403d1ec8ef7c924539d650ed8db37a617c 0.7.5
+219e38403d1ec8ef7c924539d650ed8db37a617c 0.7.5
+0000000000000000000000000000000000000000 0.7.5
+0000000000000000000000000000000000000000 0.7.5
+252b217ea18f1fb106db997bd65431e8f3011177 0.7.5
+8bc91c5a92e4416ce7ec6097208f9a6206efb700 0.7.6
+2013-03-27 version 0.7.7
+    * Fixed bug when stdout.encoding is None
+
+2013-03-26 version 0.7.6
+    * Fixed regression with --schema
+
+2013-03-23 version 0.7.5
+    * Fixed regression with Cython and multiple definitions
+
 2013-03-01 version 0.7.4
     * Fixed regression in 2.7 and recursive
 

File fastavro/__init__.py

File contents unchanged.

File fastavro/__main__.py

 
 
         if args.schema:
-            json_dump(reader.schema)
+            json_dump(reader.schema, True)
             sys.stdout.write('\n')
             continue
 

File fastavro/reader.py

File contents unchanged.

File fastavro/six.py

     unicode = str
     long = int
 
-    def json_dump(obj, indent):
+    def py3_json_dump(obj, indent):
         json.dump(obj, stdout, indent=indent)
 
 else:  # Python 2x
     unicode = unicode
     long = long
 
-    _outenc = getattr(stdout, 'encoding', _encoding)
-    def json_dump(obj, indent):
+    _outenc = getattr(stdout, 'encoding', None) or _encoding
+    def py2_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
     utob = py3_utob
+    json_dump = py3_json_dump
 else:
     btou = py2_btou
     utob = py2_utob
+    json_dump = py2_json_dump

File fastavro/writer.py

     while (datum & ~0x7F) != 0:
         fo.write(chr((datum & 0x7f) | 0x80))
         datum >>= 7
-        fo.write(chr(datum))
+    fo.write(chr(datum))
 
 write_long = write_int
 
+#!/usr/bin/env python
+
+import fastavro
+import json
+from avro.datafile import DataFileWriter
+from avro.io import DatumWriter
+import avro.schema
+
+
+def main(argv=None):
+    import sys
+    from argparse import ArgumentParser
+
+    argv = argv or sys.argv
+
+    parser = ArgumentParser(description='')
+    parser.add_argument('type', choices=['fast', 'avro'], default='fast')
+    parser.add_argument('--no-debug', '-nd', action='store_false',
+                        dest='debug', default=True)
+    parser.add_argument('--both', '-b', action='store_true', default=False)
+    args = parser.parse_args(argv[1:])
+
+
+    reader = fastavro.reader(open('tests/avro-files/weather.avro', 'rb'))
+    records = [
+        {
+            'station': 'station1',
+            'time': 7,
+            'temp': 38,
+        }
+    ]
+
+    schema = reader.schema
+    schema.pop('doc')
+
+    if args.both or args.type == 'fast':
+        with open('w-fast.avro', 'wb') as out:
+            if args.debug:
+                import pdb; pdb.set_trace()
+            fastavro.write(out, schema, records)
+    elif args.both or args.type == 'avro':
+        schema = avro.schema.parse(json.dumps(schema))
+        with open('w-avro.avro', 'wb') as out:
+            if args.debug:
+                import pdb; pdb.set_trace()
+            writer = DataFileWriter(out, DatumWriter(), schema)
+            for record in records:
+                writer.append(record)
+            writer.close()
+
+
+if __name__ == '__main__':
+    main()