[PATCH 1/2] examples: network-scan: resolve PEP8 issues

yegorslists at googlemail.com yegorslists at googlemail.com
Sat Feb 13 16:19:12 UTC 2021


From: Yegor Yefremov <yegorslists at googlemail.com>

Use autopep8 utility to resolve issues like spaces before brackets
and wrong hanging indentation.

Also treat objects like boolean variables to check whether they are
None or not.
---
 .../network-scan-python/network-scan-python   | 24 +++++++++++--------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/examples/network-scan-python/network-scan-python b/examples/network-scan-python/network-scan-python
index df295995..db12242a 100755
--- a/examples/network-scan-python/network-scan-python
+++ b/examples/network-scan-python/network-scan-python
@@ -34,17 +34,19 @@ if __name__ == "__main__":
         sys.exit(1)
 
     # Connection to ModemManager
-    connection = Gio.bus_get_sync (Gio.BusType.SYSTEM, None)
-    manager = ModemManager.Manager.new_sync (connection, Gio.DBusObjectManagerClientFlags.DO_NOT_AUTO_START, None)
-    if manager.get_name_owner() is None:
+    connection = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
+    manager = ModemManager.Manager.new_sync(
+        connection, Gio.DBusObjectManagerClientFlags.DO_NOT_AUTO_START, None)
+    if not manager.get_name_owner():
         sys.stderr.write('ModemManager not found in bus\n')
         sys.exit(2)
 
     # Iterate modems and scan network with each one by one
     for obj in manager.get_objects():
         modem3gpp = obj.get_modem_3gpp()
-        if modem3gpp is None:
-            sys.stderr.write('%s: skipping unusable modem...\n' % obj.get_object_path())
+        if not modem3gpp:
+            sys.stderr.write('%s: skipping unusable modem...\n' %
+                             obj.get_object_path())
             continue
         modem3gpp.set_default_timeout(300000)
         print('%s: starting network scan...' % modem3gpp.get_object_path())
@@ -52,10 +54,12 @@ if __name__ == "__main__":
         if networks:
             for network in networks:
                 print('%s: %s - %s (%s, %s)' % (
-                      network.get_operator_code(),
-                      network.get_operator_short(),
-                      network.get_operator_short(),
-                      ModemManager.modem_access_technology_build_string_from_mask (network.get_access_technology()),
-                      ModemManager.Modem3gppNetworkAvailability.get_string(network.get_availability())))
+                    network.get_operator_code(),
+                    network.get_operator_short(),
+                    network.get_operator_short(),
+                    ModemManager.modem_access_technology_build_string_from_mask(
+                        network.get_access_technology()),
+                    ModemManager.Modem3gppNetworkAvailability.get_string(
+                        network.get_availability())))
         else:
             print('no networks found')
-- 
2.17.0



More information about the ModemManager-devel mailing list