This software is owned by The university of
California, Irvine, and is not distributed under any version of the GPL. GPL is a fine series of licenses, but
the owners of the software need it to be distributed under these terms.
Download here (preferably via SVN checkout:
svn checkout http://stromberg.dnsalias.org/svn/readline0/trunk readline0).
readline0 is a python iterator that allows you to read data until a specific byte value is found - for example, you
can do a readline that doesn't end with a newline, but rather with a null byte, or a "g" if you like - it's quite arbitrary.
This is nice, EG, for reading filenames from GNU "find . -print0".
I've been using it in production for years.
It runs on Python 2.x and Python 3.x, including Pypy and Jython.
To get back byte strings instead of str's, pass in file_=0.
See also bufsock which can also read null terminated data, but is more about reserving the
right to read in a variety of ways.
Example use (see the unit tests for more examples):
dstromberg@zareason-strata7440 ~/src/home-svn/readline0/trunk $ /usr/local/cpython-3.6/bin/python3
Python 3.6.0 (default, Apr 22 2017, 09:17:19)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import readline0
>>> file_ = open('/etc/shells', 'r')
>>> for line in readline0.readline0(file_=file_, separator=b'\n'):
b'# /etc/shells: valid login shells'