Update README.md

This commit is contained in:
jparyani
2013-07-06 23:57:47 -07:00
parent 0ed0bcf361
commit 8705165ae2

View File

@@ -25,13 +25,11 @@ You also need a working version of the latest [Cython](http://cython.org/) insta
At the moment, there is no documenation, but the library is almost a 1:1 clone of the [Capnproto C++ Library](http://kentonv.github.io/capnproto/cxx.html)
The examples has one example that shows off the capabilities quite nicely. Here it is, reproduced:
```python
import capnp
addressbook = capnp.load('addressbook.capnp')
import os
import capnp
this_dir = os.path.dirname(__file__)
addressbook = capnp.load(os.path.join(this_dir, 'addressbook.capnp'))
def writeAddressBook(fd):
def writeAddressBook(fd):
message = capnp.MallocMessageBuilder()
addressBook = message.initRoot(addressbook.AddressBook)
people = addressBook.initPeople(2)
@@ -58,10 +56,10 @@ The examples has one example that shows off the capabilities quite nicely. Here
capnp.writePackedMessageToFd(fd, message)
f = open('example', 'w')
writeAddressBook(f.fileno())
f = open('example', 'w')
writeAddressBook(f.fileno())
def printAddressBook(fd):
def printAddressBook(fd):
message = capnp.PackedFdMessageReader(f.fileno())
addressBook = message.getRoot(addressbook.AddressBook)
@@ -83,5 +81,6 @@ The examples has one example that shows off the capabilities quite nicely. Here
print 'unemployed'
print
f = open('example', 'r')
printAddressBook(f.fileno())
f = open('example', 'r')
printAddressBook(f.fileno())
```