[OE-core] [PATCH 1/1] useradd-staticids.bbclass: Do not require trailing colons
Peter Kjellerstedt
peter.kjellerstedt at axis.com
Sat Oct 24 09:45:56 UTC 2015
I changed it to:
def list_extend(iterable, length, obj = None):
"""Ensure that iterable is the specified length by extending with obj
and return it as a list"""
return list(itertools.islice(itertools.chain(iterable, itertools.repeat(obj)), length))
because I got
Exception: TypeError: 'itertools.islice' object has no attribute '__getitem__'
otherwise.
New patch coming up.
//Peter
From: kergoth at gmail.com [mailto:kergoth at gmail.com] On Behalf Of Christopher Larson
Sent: 23 October 2015 17:53
To: Burton, Ross
Cc: Peter Kjellerstedt; OE-core
Subject: Re: [OE-core] [PATCH 1/1] useradd-staticids.bbclass: Do not require trailing colons
On Fri, Oct 23, 2015 at 8:20 AM, Burton, Ross <ross.burton at intel.com<mailto:ross.burton at intel.com>> wrote:
On 23 October 2015 at 11:38, Peter Kjellerstedt <peter.kjellerstedt at axis.com<mailto:peter.kjellerstedt at axis.com>> wrote:
- field = line.rstrip().split(":")
+ # Make sure there always are at least seven elements in
+ # the field list. This allows for leaving out trailing
+ # colons in the passwd file.
+ line = line.rstrip() + "::::::"
+ field = line.split(":")
It's a stylist thing but I prefer padding the field list instead of manipulating the input string. Something like
field = line.strip().split(":")
field += [''] * (7 - len(field))
Agreed, but I think this is cleaner:
def iter_extend(iterable, length, obj=None):
"""Ensure that iterable is the specified length by extending with obj"""
return itertools.islice(itertools.chain(iterable, itertools.repeat(obj)), length)
fields = iter_extend(line.rstrip().split(":"), 7)
--
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/openembedded-core/attachments/20151024/b475d510/attachment-0002.html>
More information about the Openembedded-core
mailing list