summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-04-10 19:02:26 +0000
committerCoprDistGit <infra@openeuler.org>2023-04-10 19:02:26 +0000
commitba2126001cd6b79d07445b8b9688496ab0c6f7bf (patch)
treefbd7d56a1fbb92c01d8f1351df31e30f573b1b1b
parent24a022e79313cfb1ef71b80ffeb2326862a408c5 (diff)
automatic import of python-pydevicetree
-rw-r--r--.gitignore1
-rw-r--r--python-pydevicetree.spec560
-rw-r--r--sources1
3 files changed, 562 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..cad9cbc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/pydevicetree-0.0.12.tar.gz
diff --git a/python-pydevicetree.spec b/python-pydevicetree.spec
new file mode 100644
index 0000000..928c114
--- /dev/null
+++ b/python-pydevicetree.spec
@@ -0,0 +1,560 @@
+%global _empty_manifest_terminate_build 0
+Name: python-pydevicetree
+Version: 0.0.12
+Release: 1
+Summary: A library for parsing Devicetree Source v1
+License: Apache Software License
+URL: https://github.com/sifive/pydevicetree
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/a1/83/c7e95b50619168ccf4c7c86a2eb6bd6896ff2dde021975b5f889eec5fddf/pydevicetree-0.0.12.tar.gz
+BuildArch: noarch
+
+Requires: python3-mypy
+Requires: python3-pyparsing
+
+%description
+# pydevicetree
+
+This is a Python 3 library for parsing, querying, and modifying Devicetree Source v1 files as
+described in the [Devicetree Specification v0.2](https://github.com/devicetree-org/devicetree-specification/releases/tag/v0.2).
+
+## Install
+
+pydevicetree supports Python >= 3.5 and can be installed with pip from the [Python Package Index](https://pypi.org/project/pydevicetree/).
+
+`pip install pydevicetree`
+
+## Tutorial
+
+### The Devicetree
+
+Let's say you have a file design.dts with the contents
+```
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "my,design";
+ aliases {
+ serial0 = "/soc/uart@10000000";
+ };
+ chosen {
+ stdout-path = "/soc/uart@10000000:115200";
+ };
+ cpus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ cpu@0 {
+ compatible = "sifive,rocket0", "riscv";
+ device_type = "cpu";
+ reg = <0>;
+ riscv,isa = "rv32imac";
+ status = "okay";
+ timebase-frequency = <1000000>;
+ sifive,dtim = <&dtim>;
+ interrupt-controller {
+ #interrupt-cells = <1>;
+ compatible = "riscv,cpu-intc";
+ interrupt-controller;
+ };
+ };
+ };
+ soc {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "my,design-soc";
+ ranges;
+ dtim: dtim@20000000 {
+ compatible = "sifive,dtim0";
+ reg = <0x20000000 0x10000000>;
+ reg-names = "mem";
+ };
+ uart: uart@10000000 {
+ compatible = "sifive,uart0";
+ reg = <0x10000000 0x1000>;
+ reg-names = "control";
+ };
+ };
+};
+```
+
+### Parsing the Tree
+
+Parsing the tree is as easy as 1, 2...
+
+```
+>>> from pydevicetree import Devicetree
+>>> tree = Devicetree.parseFile("design.dts")
+>>> tree
+<Devicetree my,design>
+```
+
+### Querying the Tree
+
+#### By `compatible` string
+
+```
+>>> tree.match("sifive,rocket0")
+[<Node cpu>]
+```
+
+#### By path
+
+```
+>>> tree.get_by_path("/soc/dtim")
+<Node dtim@20000000>
+```
+
+Devicetree aliases are allowed in paths
+
+```
+>>> tree.get_by_path("serial0")
+<Node uart@10000000>
+```
+
+#### Getting `Node` properties
+
+The value (or first value of a list/array) of a property can be retrieved with `Node.get_field()`
+
+```
+>>> tree.match("sifive,rocket0")[0].get_field("timebase-frequency")
+1000000
+```
+
+The list or array of values assigned to a property can be retrieved with `Node.get_fields()`
+
+```
+>>> tree.match("sifive,rocket0")[0].get_fields("compatible")
+<StringList ['sifive,rocket0', 'riscv']>
+```
+
+There are helper methods `Node.get_reg()` and `Node.get_ranges()` for the `reg` and `ranges`
+Devicetree properties.
+
+```
+>>> tree.get_by_path("/soc/dtim").get_reg()
+<RegArray [536870912, 268435456]>
+>>> tree.get_by_path("/soc/dtim").get_reg().get_by_name("mem")
+(536870912, 268435456)
+>>> "0x%x" % tree.get_by_path("/soc/dtim").get_reg().get_by_name("mem")[0]
+'0x20000000'
+```
+
+#### Getting `chosen` properties
+
+`Devicetree.chosen()` provides quick access to the properties of the `chosen` node
+
+```
+>>> tree.chosen("stdout-path")
+<StringList ['/soc/uart@10000000:115200']>
+```
+
+### Converting back to Devicetree
+
+Any tree or subtree can be converted back to Devicetree by calling `Node.to_dts()` or simply
+by `print`ing it:
+
+```
+>>> print(tree.match("sifive,rocket0")[0])
+cpu@0 {
+ #size-cells = <0>;
+ compatible = "sifive,rocket0", "riscv";
+ device_type = "cpu";
+ reg = <0x0>;
+ riscv,isa = "rv32imac";
+ status = "okay";
+ timebase-frequency = <1000000>;
+ sifive,dtim = <&dtim>;
+ interrupt-controller {
+ #interrupt-cells = <1>;
+ compatible = "riscv,cpu-intc";
+ interrupt-controller;
+ };
+};
+```
+
+
+
+
+%package -n python3-pydevicetree
+Summary: A library for parsing Devicetree Source v1
+Provides: python-pydevicetree
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-pydevicetree
+# pydevicetree
+
+This is a Python 3 library for parsing, querying, and modifying Devicetree Source v1 files as
+described in the [Devicetree Specification v0.2](https://github.com/devicetree-org/devicetree-specification/releases/tag/v0.2).
+
+## Install
+
+pydevicetree supports Python >= 3.5 and can be installed with pip from the [Python Package Index](https://pypi.org/project/pydevicetree/).
+
+`pip install pydevicetree`
+
+## Tutorial
+
+### The Devicetree
+
+Let's say you have a file design.dts with the contents
+```
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "my,design";
+ aliases {
+ serial0 = "/soc/uart@10000000";
+ };
+ chosen {
+ stdout-path = "/soc/uart@10000000:115200";
+ };
+ cpus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ cpu@0 {
+ compatible = "sifive,rocket0", "riscv";
+ device_type = "cpu";
+ reg = <0>;
+ riscv,isa = "rv32imac";
+ status = "okay";
+ timebase-frequency = <1000000>;
+ sifive,dtim = <&dtim>;
+ interrupt-controller {
+ #interrupt-cells = <1>;
+ compatible = "riscv,cpu-intc";
+ interrupt-controller;
+ };
+ };
+ };
+ soc {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "my,design-soc";
+ ranges;
+ dtim: dtim@20000000 {
+ compatible = "sifive,dtim0";
+ reg = <0x20000000 0x10000000>;
+ reg-names = "mem";
+ };
+ uart: uart@10000000 {
+ compatible = "sifive,uart0";
+ reg = <0x10000000 0x1000>;
+ reg-names = "control";
+ };
+ };
+};
+```
+
+### Parsing the Tree
+
+Parsing the tree is as easy as 1, 2...
+
+```
+>>> from pydevicetree import Devicetree
+>>> tree = Devicetree.parseFile("design.dts")
+>>> tree
+<Devicetree my,design>
+```
+
+### Querying the Tree
+
+#### By `compatible` string
+
+```
+>>> tree.match("sifive,rocket0")
+[<Node cpu>]
+```
+
+#### By path
+
+```
+>>> tree.get_by_path("/soc/dtim")
+<Node dtim@20000000>
+```
+
+Devicetree aliases are allowed in paths
+
+```
+>>> tree.get_by_path("serial0")
+<Node uart@10000000>
+```
+
+#### Getting `Node` properties
+
+The value (or first value of a list/array) of a property can be retrieved with `Node.get_field()`
+
+```
+>>> tree.match("sifive,rocket0")[0].get_field("timebase-frequency")
+1000000
+```
+
+The list or array of values assigned to a property can be retrieved with `Node.get_fields()`
+
+```
+>>> tree.match("sifive,rocket0")[0].get_fields("compatible")
+<StringList ['sifive,rocket0', 'riscv']>
+```
+
+There are helper methods `Node.get_reg()` and `Node.get_ranges()` for the `reg` and `ranges`
+Devicetree properties.
+
+```
+>>> tree.get_by_path("/soc/dtim").get_reg()
+<RegArray [536870912, 268435456]>
+>>> tree.get_by_path("/soc/dtim").get_reg().get_by_name("mem")
+(536870912, 268435456)
+>>> "0x%x" % tree.get_by_path("/soc/dtim").get_reg().get_by_name("mem")[0]
+'0x20000000'
+```
+
+#### Getting `chosen` properties
+
+`Devicetree.chosen()` provides quick access to the properties of the `chosen` node
+
+```
+>>> tree.chosen("stdout-path")
+<StringList ['/soc/uart@10000000:115200']>
+```
+
+### Converting back to Devicetree
+
+Any tree or subtree can be converted back to Devicetree by calling `Node.to_dts()` or simply
+by `print`ing it:
+
+```
+>>> print(tree.match("sifive,rocket0")[0])
+cpu@0 {
+ #size-cells = <0>;
+ compatible = "sifive,rocket0", "riscv";
+ device_type = "cpu";
+ reg = <0x0>;
+ riscv,isa = "rv32imac";
+ status = "okay";
+ timebase-frequency = <1000000>;
+ sifive,dtim = <&dtim>;
+ interrupt-controller {
+ #interrupt-cells = <1>;
+ compatible = "riscv,cpu-intc";
+ interrupt-controller;
+ };
+};
+```
+
+
+
+
+%package help
+Summary: Development documents and examples for pydevicetree
+Provides: python3-pydevicetree-doc
+%description help
+# pydevicetree
+
+This is a Python 3 library for parsing, querying, and modifying Devicetree Source v1 files as
+described in the [Devicetree Specification v0.2](https://github.com/devicetree-org/devicetree-specification/releases/tag/v0.2).
+
+## Install
+
+pydevicetree supports Python >= 3.5 and can be installed with pip from the [Python Package Index](https://pypi.org/project/pydevicetree/).
+
+`pip install pydevicetree`
+
+## Tutorial
+
+### The Devicetree
+
+Let's say you have a file design.dts with the contents
+```
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "my,design";
+ aliases {
+ serial0 = "/soc/uart@10000000";
+ };
+ chosen {
+ stdout-path = "/soc/uart@10000000:115200";
+ };
+ cpus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ cpu@0 {
+ compatible = "sifive,rocket0", "riscv";
+ device_type = "cpu";
+ reg = <0>;
+ riscv,isa = "rv32imac";
+ status = "okay";
+ timebase-frequency = <1000000>;
+ sifive,dtim = <&dtim>;
+ interrupt-controller {
+ #interrupt-cells = <1>;
+ compatible = "riscv,cpu-intc";
+ interrupt-controller;
+ };
+ };
+ };
+ soc {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "my,design-soc";
+ ranges;
+ dtim: dtim@20000000 {
+ compatible = "sifive,dtim0";
+ reg = <0x20000000 0x10000000>;
+ reg-names = "mem";
+ };
+ uart: uart@10000000 {
+ compatible = "sifive,uart0";
+ reg = <0x10000000 0x1000>;
+ reg-names = "control";
+ };
+ };
+};
+```
+
+### Parsing the Tree
+
+Parsing the tree is as easy as 1, 2...
+
+```
+>>> from pydevicetree import Devicetree
+>>> tree = Devicetree.parseFile("design.dts")
+>>> tree
+<Devicetree my,design>
+```
+
+### Querying the Tree
+
+#### By `compatible` string
+
+```
+>>> tree.match("sifive,rocket0")
+[<Node cpu>]
+```
+
+#### By path
+
+```
+>>> tree.get_by_path("/soc/dtim")
+<Node dtim@20000000>
+```
+
+Devicetree aliases are allowed in paths
+
+```
+>>> tree.get_by_path("serial0")
+<Node uart@10000000>
+```
+
+#### Getting `Node` properties
+
+The value (or first value of a list/array) of a property can be retrieved with `Node.get_field()`
+
+```
+>>> tree.match("sifive,rocket0")[0].get_field("timebase-frequency")
+1000000
+```
+
+The list or array of values assigned to a property can be retrieved with `Node.get_fields()`
+
+```
+>>> tree.match("sifive,rocket0")[0].get_fields("compatible")
+<StringList ['sifive,rocket0', 'riscv']>
+```
+
+There are helper methods `Node.get_reg()` and `Node.get_ranges()` for the `reg` and `ranges`
+Devicetree properties.
+
+```
+>>> tree.get_by_path("/soc/dtim").get_reg()
+<RegArray [536870912, 268435456]>
+>>> tree.get_by_path("/soc/dtim").get_reg().get_by_name("mem")
+(536870912, 268435456)
+>>> "0x%x" % tree.get_by_path("/soc/dtim").get_reg().get_by_name("mem")[0]
+'0x20000000'
+```
+
+#### Getting `chosen` properties
+
+`Devicetree.chosen()` provides quick access to the properties of the `chosen` node
+
+```
+>>> tree.chosen("stdout-path")
+<StringList ['/soc/uart@10000000:115200']>
+```
+
+### Converting back to Devicetree
+
+Any tree or subtree can be converted back to Devicetree by calling `Node.to_dts()` or simply
+by `print`ing it:
+
+```
+>>> print(tree.match("sifive,rocket0")[0])
+cpu@0 {
+ #size-cells = <0>;
+ compatible = "sifive,rocket0", "riscv";
+ device_type = "cpu";
+ reg = <0x0>;
+ riscv,isa = "rv32imac";
+ status = "okay";
+ timebase-frequency = <1000000>;
+ sifive,dtim = <&dtim>;
+ interrupt-controller {
+ #interrupt-cells = <1>;
+ compatible = "riscv,cpu-intc";
+ interrupt-controller;
+ };
+};
+```
+
+
+
+
+%prep
+%autosetup -n pydevicetree-0.0.12
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-pydevicetree -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Mon Apr 10 2023 Python_Bot <Python_Bot@openeuler.org> - 0.0.12-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..1b5bf9c
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+69c03ab7a5c4ee1e941cfb1f0d82a187 pydevicetree-0.0.12.tar.gz