avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r885948 - in /hadoop/avro/trunk: CHANGES.txt src/py/avro/protocol.py src/py/avro/schema.py
Date Tue, 01 Dec 2009 21:41:50 GMT
Author: cutting
Date: Tue Dec  1 21:41:49 2009
New Revision: 885948

URL: http://svn.apache.org/viewvc?rev=885948&view=rev
Log:
AVRO-240. In Python, try to use json module if simplejson is not available.  Contributed by
Jeff Hammerbacher.

Modified:
    hadoop/avro/trunk/CHANGES.txt
    hadoop/avro/trunk/src/py/avro/protocol.py
    hadoop/avro/trunk/src/py/avro/schema.py

Modified: hadoop/avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=885948&r1=885947&r2=885948&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Tue Dec  1 21:41:49 2009
@@ -112,6 +112,9 @@
 
     AVRO-234. C++ code cleanup. (sbanacho)
     
+    AVRO-240. In Python, if simplejson is not available, try using
+    2.6's built-in json module. (Jeff Hammerbacher via cutting)
+
   OPTIMIZATIONS
 
     AVRO-172. More efficient schema processing (massie)

Modified: hadoop/avro/trunk/src/py/avro/protocol.py
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/py/avro/protocol.py?rev=885948&r1=885947&r2=885948&view=diff
==============================================================================
--- hadoop/avro/trunk/src/py/avro/protocol.py (original)
+++ hadoop/avro/trunk/src/py/avro/protocol.py Tue Dec  1 21:41:49 2009
@@ -14,9 +14,15 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import cStringIO, md5
-import simplejson
-import avro.schema as schema
+import cStringIO
+import md5
+# Use simplejson or Python 2.6 json, prefer simplejson.
+try:
+  import simplejson as json
+except ImportError:
+  import json
+
+from avro import schema
 
 #The version implemented.
 VERSION = 1
@@ -184,5 +190,5 @@
 def parse(json_string):
   """Constructs the Protocol from the json text."""
   protocol = Protocol()
-  protocol._parse(simplejson.loads(json_string))
-  return protocol
\ No newline at end of file
+  protocol._parse(json.loads(json_string))
+  return protocol

Modified: hadoop/avro/trunk/src/py/avro/schema.py
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/py/avro/schema.py?rev=885948&r1=885947&r2=885948&view=diff
==============================================================================
--- hadoop/avro/trunk/src/py/avro/schema.py (original)
+++ hadoop/avro/trunk/src/py/avro/schema.py Tue Dec  1 21:41:49 2009
@@ -35,7 +35,13 @@
 """
 
 import cStringIO
-import simplejson, odict
+# Use simplejson or Python 2.6 json, prefer simplejson.
+try:
+  import simplejson as json
+except ImportError:
+  import json
+
+import odict
 
 # The schema types
 STRING, BYTES, INT, LONG, FLOAT, DOUBLE, BOOLEAN, NULL, \
@@ -521,5 +527,5 @@
 
 def parse(json_string):
   """Constructs the Schema from the json text."""
-  dict = simplejson.loads(json_string)
+  dict = json.loads(json_string)
   return _parse(dict, _Names())



Mime
View raw message