Update README.md
This commit is contained in:
21
README.md
21
README.md
@@ -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())
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user