On Sat, Aug 17, 2019 at 11:25:32PM +0200, Luca Weiss wrote: > Convert the usage to be compatible with Python 3 and the current API. > > Signed-off-by: Luca Weiss <luca@xxxxxxxxx> Applied, thanks. > --- > README | 26 ++++++++++++-------------- > 1 file changed, 12 insertions(+), 14 deletions(-) > > diff --git a/README b/README > index 15232ab..9465ee5 100644 > --- a/README > +++ b/README > @@ -14,45 +14,43 @@ Python library > A Python library is also available. To build this you will need to install > swig and Python development files. On Debian distributions: > > - sudo apt-get install swig python-dev > + sudo apt-get install swig python3-dev > > The library provides an Fdt class which you can use like this: > > -$ PYTHONPATH=../pylibfdt python > +$ PYTHONPATH=../pylibfdt python3 > >>> import libfdt > ->>> fdt = libfdt.Fdt(open('test_tree1.dtb').read()) > +>>> fdt = libfdt.Fdt(open('test_tree1.dtb', mode='rb').read()) > >>> node = fdt.path_offset('/subnode@1') > ->>> print node > +>>> print(node) > 124 > >>> prop_offset = fdt.first_property_offset(node) > >>> prop = fdt.get_property_by_offset(prop_offset) > ->>> print '%s=%r' % (prop.name, prop.value) > -compatible=bytearray(b'subnode1\x00') > ->>> print '%s=%s' % (prop.name, prop.value) > +>>> print('%s=%s' % (prop.name, prop.as_str())) > compatible=subnode1 > >>> node2 = fdt.path_offset('/') > ->>> print fdt.getprop(node2, 'compatible') > +>>> print(fdt.getprop(node2, 'compatible').as_str()) > test_tree1 > > You will find tests in tests/pylibfdt_tests.py showing how to use each > method. Help is available using the Python help command, e.g.: > > $ cd pylibfdt > - $ python -c "import libfdt; help(libfdt)" > + $ python3 -c "import libfdt; help(libfdt)" > > If you add new features, please check code coverage: > > - $ sudo apt-get install python-pip python-pytest > - $ sudo pip install coverage > + $ sudo apt-get install python3-coverage > $ cd tests > - $ coverage run pylibfdt_tests.py > - $ coverage html > + # It's just 'coverage' on most other distributions > + $ python3-coverage run pylibfdt_tests.py > + $ python3-coverage html > # Open 'htmlcov/index.html' in your browser > > > To install the library via the normal setup.py method, use: > > - ./pylibfdt/setup.py [--prefix=/path/to/install_dir] > + ./pylibfdt/setup.py install [--prefix=/path/to/install_dir] > > If --prefix is not provided, the default prefix is used, typically '/usr' > or '/usr/local'. See Python's distutils documentation for details. You can -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Attachment:
signature.asc
Description: PGP signature