Fix some docs

This commit is contained in:
Jason Paryani 2013-09-03 22:10:37 -07:00
parent 76a354f647
commit e80e002a6c
3 changed files with 32 additions and 9 deletions

View file

@ -24,7 +24,7 @@ pip install -U setuptools
## Building and installation
Install with `pip install pycapnp`. You can set the CC environment variable to control the compiler version, ie `CC=gcc-4.8 pip install pycapnp`.
Install with `pip install pycapnp`. You can set the CC environment variable to control which compiler is used, ie `CC=gcc-4.8 pip install pycapnp`.
Or you can clone the repo like so:
@ -116,5 +116,5 @@ If you get an error on installation like:
Then you have too old a version of setuptools. Run `pip install -U setuptools` then try again.
[![Build Status](https://travis-ci.org/jparyani/pycapnp.png?branch=master)](https://travis-ci.org/jparyani/pycapnp)
[![Build Status](https://travis-ci.org/jparyani/pycapnp.png?branch=develop)](https://travis-ci.org/jparyani/pycapnp)

View file

@ -28,7 +28,7 @@ On some systems you will have to install Python's headers before doing any of th
sudo apt-get install python-dev
You can control the compiler version with the environment variable CC, ie. `CC=gcc-4.8 pip install pycapnp`. You only need to run the setuptools line if you have a setuptools older than v0.8.0, and the cython line if you have a version older than v0.19.1.
You can control what compiler is used with the environment variable CC, ie. `CC=gcc-4.8 pip install pycapnp`. You only need to run the setuptools line if you have a setuptools older than v0.8.0, and the cython line if you have a version older than v0.19.1.
From Source
---------------------

View file

@ -199,24 +199,47 @@ The only tricky one is unions, where you need to call `.which()` to determine th
print('self employed')
print()
Dictionaries
Serializing/Deserializing
--------------
Converting to a dictionary
Files
~~~~~~~~~~~~~~~~~~~~~~~~~~
As shown in the examples above, there is file serialization with `write()`::
addresses = addressbook.AddressBook.new_message()
...
f = open('example.bin', 'w')
addresses.write(f)
And similarly for reading::
f = open('example.bin')
addresses = addressbook.AddressBook.read(f)
Dictionaries
~~~~~~~~~~~~~~
There is a convenience method for converting Cap'n Proto messages to a dictionary. This works for both Builder and Reader type messages::
alice.to_dict()
Reading froma dictionary
~~~~~~~~~~~~~~~~~~~~~~~~~~
There is a convenience method for reading for reading a dict in and building a Builder message out of it. This the inverse of `Converting to a dictionary`_::
There is also a convenience method for reading for reading a dict in and building a Builder message out of it. This the inverse of the above::
my_dict = {'name' : 'alice'}
alice = addressbook.Person.from_dict(my_dict)
Byte Strings/Buffers
~~~~~~~~~~~~~~~~~~~~~
There is serialization to a byte string available::
encoded_message = alice.to_bytes()
And a corresponding from_bytes function::
alice addressbook.Person.from_bytes(encoded_message)
Full Example
------------------