]> code.ossystems Code Review - openembedded-core.git/commit
useradd-staticids.bbclass: Simplify some logic
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>
Fri, 18 Dec 2015 23:53:49 +0000 (00:53 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 17 Jan 2016 11:32:20 +0000 (11:32 +0000)
commit274d38a6e2183ec88335a08b963f26c34b328558
tree7d8fdeea9f023920c3c9df66ecc022b6d0a3fad4
parent0e5402c433739a416a76df532378533cb25365c7
useradd-staticids.bbclass: Simplify some logic

The [<on_true>, <on_false>][not <condition>] construct may solve the
problem of implementing a conditional operator, but it is not very
readable. At least I find this:

    uaargs.groupid = field[3] or uaargs.gid or uaargs.groupname

a lot more readable than this:

    uaargs.groupid = [uaargs.gid, uaargs.groupname][not uaargs.gid]
    uaargs.groupid = [field[3], uaargs.groupid][not field[3]]

Also, the official conditional operator since Python 2.5 (<on_true> if
<condition> else <on_false>) does not evaluate both <on_false> and
<on_true> as [<on_true>, <on_false>][not <condition>] does.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/useradd-staticids.bbclass