diff --git a/CHANGES.txt b/CHANGES.txt new file mode 100644 index 0000000..156affd --- /dev/null +++ b/CHANGES.txt @@ -0,0 +1,2 @@ +0.1, 2013-02-13 -- Initial release. + diff --git a/LICENSE b/LICENSE.txt similarity index 100% rename from LICENSE rename to LICENSE.txt diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..748b55f --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,5 @@ +include *.txt +include *.md +include Makefile +graft flojay + diff --git a/README b/README new file mode 100644 index 0000000..c299594 --- /dev/null +++ b/README @@ -0,0 +1,56 @@ +# flojay + +flojay provides incremental serialization of Python data structures as +JSON documents, and an event-based JSON parser to allow for incremtnal +deserialization. It can be used to create and process JSON documents +that are larger than working memory. + +It is based on [yajl](http://lloyd.github.com/yajl/) version 2, a +copy of which is included in this distribution. + +# example + + import flojay + import sys + + # Produce JSON from a generator, printing partial results + # as they become available + + encoder = flojay.JSONEncoder() + json_generator = encoder.iterencode(xrange(100)) + for hunk in json_generator: + print hunk + + + # Read an array of JSON numbers from stdin input, + # summing the values as they are read + + + class ExampleCallbacks(object): + def __init__(self): + self.sum = 0 + + def handle_start_array(self): + pass + + def handle_end_array(self): + pass + + def handle_number(self, value): + self.sum += value + + callbacks = ExampleCallbacks() + + parser = flojay.JSONEventParser(callbacks) + + while 1: + row = sys.stdin.readline() + if len(row) == 0: + break + parser.parse(row) + print "The current total is: %d" % (callbacks.sum,) + + +# Thank also to + +Lloyd Hilaiel -- creator of yajl -- https://github.com/lloyd diff --git a/README.md b/README.md index 92d4bf9..c299594 100644 --- a/README.md +++ b/README.md @@ -49,4 +49,8 @@ copy of which is included in this distribution. break parser.parse(row) print "The current total is: %d" % (callbacks.sum,) - + + +# Thank also to + +Lloyd Hilaiel -- creator of yajl -- https://github.com/lloyd diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..92d4bf9 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,52 @@ +# flojay + +flojay provides incremental serialization of Python data structures as +JSON documents, and an event-based JSON parser to allow for incremtnal +deserialization. It can be used to create and process JSON documents +that are larger than working memory. + +It is based on [yajl](http://lloyd.github.com/yajl/) version 2, a +copy of which is included in this distribution. + +# example + + import flojay + import sys + + # Produce JSON from a generator, printing partial results + # as they become available + + encoder = flojay.JSONEncoder() + json_generator = encoder.iterencode(xrange(100)) + for hunk in json_generator: + print hunk + + + # Read an array of JSON numbers from stdin input, + # summing the values as they are read + + + class ExampleCallbacks(object): + def __init__(self): + self.sum = 0 + + def handle_start_array(self): + pass + + def handle_end_array(self): + pass + + def handle_number(self, value): + self.sum += value + + callbacks = ExampleCallbacks() + + parser = flojay.JSONEventParser(callbacks) + + while 1: + row = sys.stdin.readline() + if len(row) == 0: + break + parser.parse(row) + print "The current total is: %d" % (callbacks.sum,) + diff --git a/tests/marshal_tests.py b/flojay/tests/marshal_tests.py similarity index 100% rename from tests/marshal_tests.py rename to flojay/tests/marshal_tests.py diff --git a/tests/unmarshal_tests.py b/flojay/tests/unmarshal_tests.py similarity index 100% rename from tests/unmarshal_tests.py rename to flojay/tests/unmarshal_tests.py diff --git a/setup.py b/setup.py index 6b3a7ad..43f5ce6 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ ('yajl.c', 'yajl_gen.c', 'yajl_alloc.c', 'yajl_lex.c', 'yajl_tree.c', \ 'yajl_encode.c', 'yajl_version.c', 'yajl_buf.c', 'yajl_parser.c')] -flojay = Extension('flojay', +flojay_extension = Extension('flojay', define_macros=[ ('MAJOR_VERSION', '0'), ('MINOR_VERSION', '1')], @@ -13,15 +13,26 @@ include_dirs=['flojay/lloyd-yajl/src'], sources=yajl_sources + ['flojay/flojay.c']) +setup( + name='flojay', + version='0.1', + description='Streaming and event-based JSON parser based on yajl', + author='Robert Church', + author_email='rchurch@myemma.com', + url = "http://github/myemma/flojay/", + ext_modules=[flojay_extension], + packages=['flojay'], + install_requires=['nose==1.1.2'], + keywords = ["json", "stream", "ajax", "webapp", "website", "data", "messaging"], + classifiers = [ + "Programming Language :: Python", + "Development Status :: 2 - Pre-Alpha", + "Environment :: Other Environment", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Internet", + ], + ) -setup(name='flojay', - version='0.1', - description='Streaming or event-based JSON parser based on yajl', - author='Robert Church', - author_email='rchurch@myemma.com', - url='', - ext_modules=[flojay], - packages=['flojay'], - install_requires=[ - 'nose==1.1.2', - ])