Re: [RFC v2 02/15] test: Add utility library for python scripts

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

 



Hi Mikel,

On Thu, Nov 29, 2012 at 8:47 AM, Mikel Astiz <mikel.astiz.oss@xxxxxxxxx> wrote:
> +def find_adapter_in_objects(objects, pattern=None):
> +       bus = dbus.SystemBus()
> +       for path, ifaces in objects.iteritems():
> +               adapter = ifaces.get(ADAPTER_INTERFACE)
> +               if adapter == None:
> +                       continue

It is usually considered bad to use "== None" in Python. Either use
"adapter is None" or just "not adapter" (which is broader, but is
probably okay in this context).

> +               if (pattern == None or pattern == adapter["Address"] or
> +                                                       path.endswith(pattern)):

Same here, better use "pattern is None" or "not pattern" (which will
also match empty strings, which will always match due to the
"endswith()" usage).

> +                       obj = bus.get_object(SERVICE_NAME, path)
> +                       return dbus.Interface(obj, ADAPTER_INTERFACE)
> +       raise Exception("Bluetooth adapter not found")

Regards,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux