[PATCH 2/2] README: update for Python 3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Convert the usage to be compatible with Python 3 and the current API.

Signed-off-by: Luca Weiss <luca@xxxxxxxxx>
---
 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
-- 
2.22.0




[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux