Re: [PATCH v3 2/4] Make Property a subclass of bytearray

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



On Thu, May 17, 2018 at 11:09:14PM -0600, Simon Glass wrote:
> It is annoying to have to add .value when we want the value of a Property.
> Make Property a subclass of bytearray so that it can be used directly when
> the value is required.
> 
> Fix the Property class comment while we are here.
> 
> Suggested-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Simon Glass <sjg@xxxxxxxxxxxx>

Applied, thanks.

> ---
> 
> Changes in v3:
> - New patch
> 
> Changes in v2: None
> 
>  pylibfdt/libfdt.i       | 7 ++++---
>  tests/pylibfdt_tests.py | 2 +-
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i
> index 29695bb..2c104ac 100644
> --- a/pylibfdt/libfdt.i
> +++ b/pylibfdt/libfdt.i
> @@ -418,7 +418,8 @@ class Fdt:
>          """
>          return check_err(fdt_node_offset_by_phandle(self._fdt, phandle), quiet)
>  
> -class Property:
> +
> +class Property(bytearray):
>      """Holds a device tree property name and value.
>  
>      This holds a copy of a property taken from the device tree. It does not
> @@ -427,11 +428,11 @@ class Property:
>  
>      Properties:
>          name: Property name
> -        value: Proper value as a bytearray
> +        value: Property value as a bytearray
>      """
>      def __init__(self, name, value):
> +        bytearray.__init__(self, value)
>          self.name = name
> -        self.value = value
>  %}
>  
>  %rename(fdt_property) fdt_property_func;
> diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py
> index 0ec0f38..343a1e4 100644
> --- a/tests/pylibfdt_tests.py
> +++ b/tests/pylibfdt_tests.py
> @@ -190,7 +190,7 @@ class PyLibfdtTests(unittest.TestCase):
>          poffset = self.fdt.first_property_offset(root)
>          prop = self.fdt.get_property_by_offset(poffset)
>          self.assertEquals(prop.name, 'compatible')
> -        self.assertEquals(prop.value, 'test_tree1\0')
> +        self.assertEquals(prop, 'test_tree1\0')
>  
>          with self.assertRaises(FdtException) as e:
>              self.fdt.get_property_by_offset(-2)

-- 
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


[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