Re: [libgpiod v2][PATCH v3 2/4] bindings: python: add examples

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

 



On Mon, Oct 17, 2022 at 02:00:15PM +0200, Bartosz Golaszewski wrote:
> On Thu, Oct 13, 2022 at 5:09 AM Kent Gibson <warthog618@xxxxxxxxx> wrote:
> >
> > On Fri, Oct 07, 2022 at 04:55:19PM +0200, Bartosz Golaszewski wrote:
> > > This adds the regular set of example programs implemented using libgpiod
> > > python bindings.
> > >
> > > Signed-off-by: Bartosz Golaszewski <brgl@xxxxxxxx>
> > > +    path = sys.argv[1]
> > > +    values = dict()
> > > +    lines = []
> > > +    for arg in sys.argv[2:]:
> > > +        arg = arg.split("=")
> > > +        key = int(arg[0]) if arg[0].isdigit() else arg[0]
> > > +        val = int(arg[1])
> > > +
> > > +        lines.append(key)
> > > +        values[key] = Value(val)
> > > +
> >
> >         lvs = [ arg.split('=') for arg in sys.argv[2:] ]
            lvs = [ (x,int(y)) for (x,y) in lvs ]
> >         lines = [ x[0] for x in lvs ]
> >         values = dict(lvs)
> 

An extra pass to fix the int values.
You could do it in one with a more appropriate parser function.

Cheers,
Kent.




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux