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: kerg...@gmail.com [mailto:kerg...@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.bur...@intel.com<mailto:ross.bur...@intel.com>> wrote:
On 23 October 2015 at 11:38, Peter Kjellerstedt 
<peter.kjellerst...@axis.com<mailto:peter.kjellerst...@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
-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Reply via email to