From 8dc784c133ea0b0c25b796ac670bc8d660252423 Mon Sep 17 00:00:00 2001 From: Jiri Popelka Date: Tue, 25 Aug 2015 13:07:58 +0200 Subject: [PATCH] Compare with None should be done with 'is [not]', not equality operator. PEP 8 says: Comparisons to singletons like None should always be done with 'is' or 'is not', never the equality operators. --- OpenPrintingRequest.py | 2 +- PhysicalDevice.py | 22 +++--- applet.py | 2 +- asyncconn.py | 2 +- asyncipp.py | 26 +++---- asyncpk1.py | 6 +- authconn.py | 16 ++-- check-device-ids.py | 6 +- cupshelpers/cupshelpers.py | 12 +-- cupshelpers/openprinting.py | 39 +++++----- cupshelpers/ppds.py | 14 ++-- cupshelpers/xmldriverprefs.py | 10 +-- cupspk.py | 18 ++--- firewallsettings.py | 6 +- gui.py | 2 +- install-printerdriver.py | 2 +- installpackage.py | 12 +-- jobviewer.py | 68 ++++++++-------- monitor.py | 18 ++--- newprinter.py | 98 ++++++++++++------------ options.py | 20 ++--- optionwidgets.py | 2 +- ppdsloader.py | 12 +-- printerproperties.py | 18 ++--- probe_printer.py | 6 +- scp-dbus-service.py | 6 +- statereason.py | 4 +- system-config-printer.py | 36 ++++----- test_PhysicalDevice.py | 2 +- test_ppds.py | 4 +- timedops.py | 10 +-- troubleshoot/CheckNetworkServerSanity.py | 2 +- troubleshoot/CheckPPDSanity.py | 6 +- troubleshoot/CheckUSBPermissions.py | 2 +- troubleshoot/ChooseNetworkPrinter.py | 8 +- troubleshoot/ChoosePrinter.py | 8 +- troubleshoot/DeviceListed.py | 2 +- troubleshoot/ErrorLogFetch.py | 6 +- troubleshoot/Locale.py | 8 +- troubleshoot/PrintTestPage.py | 10 +-- userdefault.py | 4 +- xml/validate.py | 4 +- 42 files changed, 281 insertions(+), 280 deletions(-) diff --git a/OpenPrintingRequest.py b/OpenPrintingRequest.py index dc103005f..4f1a1f177 100644 --- a/OpenPrintingRequest.py +++ b/OpenPrintingRequest.py @@ -62,7 +62,7 @@ def __del__ (self): def cancel (self): debugprint ("%s: cancel()" % self) - if self._handle != None: + if self._handle is not None: self.openprinting.cancelOperation (self._handle) self._handle = None diff --git a/PhysicalDevice.py b/PhysicalDevice.py index c917b7592..dfe3ba171 100644 --- a/PhysicalDevice.py +++ b/PhysicalDevice.py @@ -60,7 +60,7 @@ def _get_host_from_uri (self, uri): if rest.startswith ("/net/"): (rest, ipparam) = urllib.parse.splitquery (rest[5:]) - if ipparam != None: + if ipparam is not None: if ipparam.startswith("ip="): hostport = ipparam[3:] elif ipparam.startswith ("hostname="): @@ -77,7 +77,7 @@ def _get_host_from_uri (self, uri): return None, None else: (hostport, rest) = urllib.parse.splithost (rest) - if hostport == None: + if hostport is None: return None, None if hostport: @@ -90,19 +90,19 @@ def add_device (self, device): host, dnssdhost = self._get_host_from_uri (device.uri) if (hasattr (device, 'address')): host = device.address - if (hasattr (device, 'hostname') and dnssdhost == None): + if (hasattr (device, 'hostname') and dnssdhost is None): dnssdhost = device.hostname - if (host == None and dnssdhost == None) or \ + if (host is None and dnssdhost is None) or \ (host and self._network_host and \ host != self._network_host) or \ (dnssdhost and self.dnssd_hostname and \ dnssdhost != self.dnssd_hostname) or \ - (host == None and self.dnssd_hostname == None) or \ - (dnssdhost == None and self._network_host == None): + (host is None and self.dnssd_hostname is None) or \ + (dnssdhost is None and self._network_host is None): raise ValueError else: (mfg, mdl) = self._canonical_id (device) - if self.devices == None: + if self.devices is None: self.mfg = mfg self.mdl = mdl self.mfg_lower = mfg.lower () @@ -157,11 +157,11 @@ def count_lower (s): if dnssdhost: self.dnssd_hostname = dnssdhost; - if (hasattr (device, 'address') and self._network_host == None): + if (hasattr (device, 'address') and self._network_host is None): address = device.address if address: self._network_host = address - if (hasattr (device, 'hostname') and self.dnssd_hostname == None): + if (hasattr (device, 'hostname') and self.dnssd_hostname is None): hostname = device.hostname if hostname: self.dnssd_hostname = hostname @@ -275,10 +275,10 @@ def __lt__(self, other): return False if self._network_host != other._network_host: - if self._network_host == None: + if self._network_host is None: return True - if other._network_host == None: + if other._network_host is None: return False return self._network_host < other._network_host diff --git a/applet.py b/applet.py index 0b7c1df6c..959e5c810 100644 --- a/applet.py +++ b/applet.py @@ -361,7 +361,7 @@ def handle_dbus_signal (self, *args): def check_for_jobs (self, *args): debugprint ("checking for jobs") if any_jobs (): - if self.timer != None: + if self.timer is not None: GLib.source_remove (self.timer) self.remove_signal_receiver () diff --git a/asyncconn.py b/asyncconn.py index 55f4f3467..abf0ce839 100644 --- a/asyncconn.py +++ b/asyncconn.py @@ -114,7 +114,7 @@ def __init__ (self, reply_handler=None, error_handler=None, self._destroyed = False # Decide whether to use direct IPP or PolicyKit. - if host == None: + if host is None: host = cups.getServer() use_pk = ((host.startswith ('/') or host == 'localhost') and os.getuid () != 0) diff --git a/asyncipp.py b/asyncipp.py index 5fb189d0f..5bc160e0f 100644 --- a/asyncipp.py +++ b/asyncipp.py @@ -71,11 +71,11 @@ def set_auth_info (self, password): self._auth_queue.put (password) def run (self): - if self.host == None: + if self.host is None: self.host = cups.getServer () - if self.port == None: + if self.port is None: self.port = cups.getPort () - if self._encryption == None: + if self._encryption is None: self._encryption = cups.getEncryption () if self.user: @@ -100,7 +100,7 @@ def run (self): self.idle = self._queue.empty () item = self._queue.get () debugprint ("Next task: %s" % repr (item)) - if item == None: + if item is None: # Our signal to quit. self._queue.task_done () break @@ -176,7 +176,7 @@ def stop (self): def _auth (self, prompt, conn=None, method=None, resource=None): def prompt_auth (prompt): Gdk.threads_enter () - if conn == None: + if conn is None: self._auth_handler (prompt, self._conn) else: self._auth_handler (prompt, self._conn, method, resource) @@ -184,7 +184,7 @@ def prompt_auth (prompt): Gdk.threads_leave () return False - if self._auth_handler == None: + if self._auth_handler is None: return "" GLib.idle_add (prompt_auth, prompt) @@ -349,7 +349,7 @@ def _destroy (self): del self._client_error_handler def error_handler (self, conn, exc): - if self._client_fn == None: + if self._client_fn is None: # This is the initial "connection" operation, or a # subsequent reconnection attempt. debugprint ("Connection/reconnection failed") @@ -433,7 +433,7 @@ def error_handler (self, conn, exc): def auth_handler (self, prompt, conn, method=None, resource=None): if self._auth_called == False: - if self._user == None: + if self._user is None: self._user = cups.getUser() if self._user: host = conn.thread.host @@ -479,7 +479,7 @@ def auth_handler (self, prompt, conn, method=None, resource=None): if conn.semantic: op = conn.semantic.current_operation () - if op == None: + if op is None: d = authconn.AuthDialog (parent=conn.parent) else: title = _("Authentication (%s)") % op @@ -487,7 +487,7 @@ def auth_handler (self, prompt, conn, method=None, resource=None): parent=conn.parent) d.set_prompt ('') - if self._user == None: + if self._user is None: self._user = cups.getUser() d.set_auth_info (['', '']) d.field_grab_focus ('username') @@ -543,7 +543,7 @@ def _reconnect_reply (self, conn, result): # so we've reconnected as that user. Alternatively, the # connection has failed and we're retrying. debugprint ("Connected as %s" % self._user) - if self._client_fn != None: + if self._client_fn is not None: self.submit_task () def _reconnect_error (self, conn, exc): @@ -556,7 +556,7 @@ def _reconnect_error (self, conn, exc): if conn.semantic: op = conn.semantic.current_operation () - if op == None: + if op is None: msg = _("CUPS server error") else: msg = _("CUPS server error (%s)") % op @@ -567,7 +567,7 @@ def _reconnect_error (self, conn, exc): buttons=Gtk.ButtonsType.NONE, text=msg) - if self._client_fn == None and type (exc) == RuntimeError: + if self._client_fn is None and type (exc) == RuntimeError: # This was a connection failure. message = 'service-error-service-unavailable' elif type (exc) == cups.IPPError: diff --git a/asyncpk1.py b/asyncpk1.py index 4c1c865df..65d2e768d 100644 --- a/asyncpk1.py +++ b/asyncpk1.py @@ -242,7 +242,7 @@ def __init__(self, reply_handler=None, error_handler=None, self._system_bus = None global _DevicesGet_uses_new_api - if _DevicesGet_uses_new_api == None and self._system_bus: + if _DevicesGet_uses_new_api is None and self._system_bus: try: obj = self._system_bus.get_object(CUPS_PK_NAME, CUPS_PK_PATH) proxy = dbus.Interface (obj, dbus.INTROSPECTABLE_IFACE) @@ -324,7 +324,7 @@ def _args_kwds_to_tuple (self, types, params, args, kwds): del leftover_kwds["auth_handler"] result = [True, reply_handler, error_handler, ()] - if self._system_bus == None: + if self._system_bus is None: return result tup = [] @@ -461,7 +461,7 @@ def _unpack_getDevices_reply (self, dbusdict): else: device_uri = result_str[keywithaffix] - if device_uri != None: + if device_uri is not None: devices[device_uri] = device_dict n += 1 diff --git a/authconn.py b/authconn.py index 934942500..65f221bf0 100644 --- a/authconn.py +++ b/authconn.py @@ -43,7 +43,7 @@ def __init__ (self, title=None, parent=None, Gtk.STOCK_OK, Gtk.ResponseType.OK), auth_info_required=None, allow_remember=False): - if title == None: + if title is None: title = _("Authentication") if auth_info_required is None: auth_info_required = ['username', 'password'] @@ -124,13 +124,13 @@ def __init__ (self): self.creds = dict() # by (host,port) def cache_auth_info (self, data, host=None, port=None): - if port == None: + if port is None: port = 631 self.creds[(host,port)] = data def lookup_auth_info (self, host=None, port=None): - if port == None: + if port is None: port = 631 try: @@ -139,7 +139,7 @@ def lookup_auth_info (self, host=None, port=None): return None def remove_auth_info (self, host=None, port=None): - if port == None: + if port is None: port = 631 try: @@ -152,11 +152,11 @@ def remove_auth_info (self, host=None, port=None): class Connection: def __init__ (self, parent=None, try_as_root=True, lock=False, host=None, port=None, encryption=None): - if host != None: + if host is not None: cups.setServer (host) - if port != None: + if port is not None: cups.setPort (port) - if encryption != None: + if encryption is not None: cups.setEncryption (encryption) self._use_password = '' @@ -341,7 +341,7 @@ def _perform_authentication (self): self._passes += 1 creds = global_authinfocache.lookup_auth_info (host=self._server, port=self._port) - if creds != None: + if creds is not None: if (creds[0] != 'root' or self._try_as_root): (self._use_user, self._use_password) = creds del creds diff --git a/check-device-ids.py b/check-device-ids.py index a210e3d80..acb22ff7f 100755 --- a/check-device-ids.py +++ b/check-device-ids.py @@ -64,7 +64,7 @@ "by temporarily disabling your firewall (or by allowing\n" "incoming UDP packets on port 161).\n") -if devices == None: +if devices is None: if not SPECIFIC_URI: print("Examining connected devices") @@ -87,7 +87,7 @@ sys.exit (1) if SPECIFIC_URI: - if devices.get (SPECIFIC_URI) == None: + if devices.get (SPECIFIC_URI) is None: devices = { SPECIFIC_URI: { 'device-make-and-model': '', 'device-id': ''} } @@ -123,7 +123,7 @@ devs = [] def got_device (dev): - if dev != None: + if dev is not None: devs.append (dev) import probe_printer diff --git a/cupshelpers/cupshelpers.py b/cupshelpers/cupshelpers.py index 3c502eb9f..316396b27 100755 --- a/cupshelpers/cupshelpers.py +++ b/cupshelpers/cupshelpers.py @@ -55,7 +55,7 @@ def __init__(self, name, connection, **kw): self._ppd = None # load on demand def __del__ (self): - if self._ppd != None: + if self._ppd is not None: os.unlink(self._ppd) def __repr__ (self): @@ -210,7 +210,7 @@ def getPPD(self): else: raise - if result == None and self._ppd != None: + if result is None and self._ppd is not None: result = cups.PPD (self._ppd) return result @@ -368,7 +368,7 @@ def jobsQueued(self, only_tests=False, limit=None): attrs['job-name'] == 'Test Page')): ret.append (id) - if limit != None and len (ret) == limit: + if limit is not None and len (ret) == limit: break return ret @@ -402,7 +402,7 @@ def jobsPreserved(self, limit=None): cups.IPP_JOB_PENDING) < cups.IPP_JOB_COMPLETED): continue ret.append (id) - if limit != None and len (ret) == limit: + if limit is not None and len (ret) == limit: break return ret @@ -546,7 +546,7 @@ def __lt__(self, other): """ Compare devices by order of preference. """ - if other == None: + if other is None: return True if self.is_class != other.is_class: @@ -665,7 +665,7 @@ def activateNewPrinter(connection, name): connection.acceptJobs (name) # Set as the default if there is not already a default printer. - if connection.getDefault () == None: + if connection.getDefault () is None: connection.setDefault (name) def copyPPDOptions(ppd1, ppd2): diff --git a/cupshelpers/openprinting.py b/cupshelpers/openprinting.py index c3c6de1e1..285442dba 100755 --- a/cupshelpers/openprinting.py +++ b/cupshelpers/openprinting.py @@ -73,10 +73,11 @@ def run (self): status = 0 except: self.result = sys.exc_info () - if status == None: status = 0 + if status is None: + status = 0 _debugprint ("%s: query complete" % self) - if self.callback != None: + if self.callback is not None: self.callback (status, self.user_data, self.result) class OpenPrinting: @@ -86,7 +87,7 @@ def __init__(self, language=None): locale.setlocale(). @type language: string """ - if language == None: + if language is None: import locale try: language = locale.getlocale(locale.LC_MESSAGES) @@ -165,7 +166,7 @@ def parse_result (status, data, result): id = printer.find ("id") make = printer.find ("make") model = printer.find ("model") - if id != None and make != None and model != None: + if id is not None and make is not None and model is not None: idtxt = id.text maketxt = make.text modeltxt = model.text @@ -266,25 +267,25 @@ def parse_result (status, data, result): for driver in root.findall ('driver'): id = driver.attrib.get ('id') - if id == None: + if id is None: continue dict = {} for attribute in ['name', 'url', 'supplier', 'license', 'shortdescription' ]: element = driver.find (attribute) - if element != None and element.text != None: + if element is not None and element.text is not None: dict[attribute] = _normalize_space (element.text) element = driver.find ('licensetext') - if element != None and element.text != None: + if element is not None and element.text is not None: dict['licensetext'] = element.text if not 'licensetext' in dict or \ - dict['licensetext'] == None: + dict['licensetext'] is None: element = driver.find ('licenselink') - if element != None: + if element is not None: license_url = element.text - if license_url != None: + if license_url is not None: try: req = requests.get(license_url, verify=True) dict['licensetext'] = \ @@ -296,7 +297,7 @@ def parse_result (status, data, result): for boolean in ['nonfreesoftware', 'recommended', 'patents', 'thirdpartysupplied', 'manufacturersupplied']: - dict[boolean] = driver.find (boolean) != None + dict[boolean] = driver.find (boolean) is not None # Make a 'freesoftware' tag for compatibility with # how the OpenPrinting API used to work (see trac @@ -305,10 +306,10 @@ def parse_result (status, data, result): supportcontacts = [] container = driver.find ('supportcontacts') - if container != None: + if container is not None: for sc in container.findall ('supportcontact'): supportcontact = {} - if sc.text != None: + if sc.text is not None: supportcontact['name'] = \ _normalize_space (sc.text) else: @@ -324,19 +325,19 @@ def parse_result (status, data, result): continue container = driver.find ('functionality') - if container != None: + if container is not None: functionality = {} for attribute in ['text', 'lineart', 'graphics', 'photo', 'speed']: element = container.find (attribute) - if element != None: + if element is not None: functionality[attribute] = element.text if functionality: dict[container.tag] = functionality packages = {} container = driver.find ('packages') - if container != None: + if container is not None: for arch in container.getchildren (): rpms = {} for package in arch.findall ('package'): @@ -345,11 +346,11 @@ def parse_result (status, data, result): 'release', 'url', 'pkgsys', 'fingerprint']: element = package.find (attribute) - if element != None: + if element is not None: rpm[attribute] = element.text repositories = package.find ('repositories') - if repositories != None: + if repositories is not None: for pkgsys in repositories.getchildren (): rpm.setdefault('repositories', {})[pkgsys.tag] = pkgsys.text @@ -361,7 +362,7 @@ def parse_result (status, data, result): ppds = [] container = driver.find ('ppds') - if container != None: + if container is not None: for each in container.getchildren (): ppds.append (each.text) diff --git a/cupshelpers/ppds.py b/cupshelpers/ppds.py index 03be36e63..f79550ce1 100755 --- a/cupshelpers/ppds.py +++ b/cupshelpers/ppds.py @@ -139,7 +139,7 @@ def ppdMakeModelSplit (ppd_make_and_model): break # Handle PPDs provided by Turboprint - if make == None and _RE_turboprint.search (l): + if make is None and _RE_turboprint.search (l): t = ppd_make_and_model.find (" TurboPrint") if t != -1: t2 = ppd_make_and_model.rfind (" TurboPrint") @@ -344,9 +344,9 @@ def __init__ (self, ppds, language=None, xml_dir=None): self.drivertypes = xmldriverprefs.DriverTypes () self.preforder = xmldriverprefs.PreferenceOrder () - if xml_dir == None: + if xml_dir is None: xml_dir = os.environ.get ("CUPSHELPERS_XMLDIR") - if xml_dir == None: + if xml_dir is None: from . import config xml_dir = os.path.join (config.sysconfdir, "cupshelpers") @@ -361,7 +361,7 @@ def __init__ (self, ppds, language=None, xml_dir=None): self.drivertypes = None self.preforder = None - if (language == None or + if (language is None or language == "C" or language == "POSIX"): language = "en_US" @@ -488,7 +488,7 @@ def orderPPDNamesByPreference (self, ppdnamelist=None, if downloadedfiles is None: downloadedfiles = [] - if fit == None: + if fit is None: fit = {} if self.drivertypes and self.preforder: @@ -618,7 +618,7 @@ def getPPDNamesFromDeviceID (self, mfg, mdl, description="", make = self.lmakes[mfgl] _debugprint ("make: %s" % make) - if make != None: + if make is not None: mdls = self.makes[make] mdlsl = self.lmodels[normalize(make)] @@ -904,7 +904,7 @@ def _findBestMatchPPDs (self, mdls, mdl): mdlitems = [(x.lower (), mdls[x]) for x in mdlnames] modelid = None for word in mdll.split (' '): - if modelid == None: + if modelid is None: modelid = word have_digits = False diff --git a/cupshelpers/xmldriverprefs.py b/cupshelpers/xmldriverprefs.py index 4f8ac646b..4177e1c0f 100644 --- a/cupshelpers/xmldriverprefs.py +++ b/cupshelpers/xmldriverprefs.py @@ -99,7 +99,7 @@ def add_ppd_name (self, pattern): # If the PPD name pattern includes a scheme, we can perhaps # deduce which package would provide this driver type. - if self._packagehint != None: + if self._packagehint is not None: return parts = pattern.split (":", 1) @@ -388,7 +388,7 @@ def match (self, make_and_model, deviceid): Return False otherwise. """ - matches = (self.make_and_model == None and self.deviceid == []) + matches = (self.make_and_model is None and self.deviceid == []) if self.make_and_model: if self.make_and_model.match (make_and_model): matches = True @@ -451,10 +451,10 @@ def get_ordered_types (self, drivertypes, make_and_model, deviceid): short-form upper-case field keys. """ - if deviceid == None: + if deviceid is None: deviceid = {} - if make_and_model == None: + if make_and_model is None: make_and_model = "" orderedtypes = [] @@ -520,7 +520,7 @@ def debugprint (x): ppds.set_debugprint_fn (debugprint) locale.setlocale (locale.LC_ALL, "") - if xml_path == None: + if xml_path is None: xml_path = os.path.join (os.path.join (os.path.dirname (__file__), ".."), "xml") diff --git a/cupspk.py b/cupspk.py index fbe223efa..c9aab035e 100644 --- a/cupspk.py +++ b/cupspk.py @@ -172,7 +172,7 @@ def _args_to_tuple(self, types, *args): # we accept a mix between bool and str retval.append(str(args[i])) continue - elif types[i] == str and args[i] == None: + elif types[i] == str and args[i] is None: # None is an empty string for dbus retval.append('') continue @@ -180,7 +180,7 @@ def _args_to_tuple(self, types, *args): # we accept a mix between list and tuple retval.append(list(args[i])) continue - elif types[i] == list and args[i] == None: + elif types[i] == list and args[i] is None: # None is an empty list retval.append([]) continue @@ -272,7 +272,7 @@ def getDevices(self, *args, **kwds): return result result_str = {} - if result != None: + if result is not None: for i in result.keys(): if type(i) == dbus.String: result_str[str(i)] = str(result[i]) @@ -297,7 +297,7 @@ def getDevices(self, *args, **kwds): else: device_uri = result_str[i] - if device_uri != None: + if device_uri is not None: devices[device_uri] = device_dict n += 1 @@ -382,7 +382,7 @@ def getFile(self, *args, **kwds): else: filename = None - if (not use_pycups) and (fd != None or file_object != None): + if (not use_pycups) and (fd is not None or file_object is not None): # Create the temporary file in /tmp to ensure that # cups-pk-helper-mechanism is able to write to it. (tmpfd, tmpfname) = tempfile.mkstemp(dir="/tmp") @@ -398,7 +398,7 @@ def getFile(self, *args, **kwds): tmpfile = os.fdopen (tmpfd, 'rt') tmpfile.seek (0) - if fd != None: + if fd is not None: os.lseek (fd, 0, os.SEEK_SET) line = tmpfile.readline() while line != '': @@ -439,11 +439,11 @@ def putFile(self, *args, **kwds): else: filename = None - if (not use_pycups) and (fd != None or file_object != None): + if (not use_pycups) and (fd is not None or file_object is not None): (tmpfd, tmpfname) = tempfile.mkstemp() os.lseek (tmpfd, 0, os.SEEK_SET) - if fd != None: + if fd is not None: os.lseek (fd, 0, os.SEEK_SET) buf = os.read (fd, 512) while buf != '': @@ -725,7 +725,7 @@ def adminGetServerSettings(self, *args, **kwds): self._connection.adminGetServerSettings, *args, **kwds) settings = {} - if result != None: + if result is not None: for i in result.keys(): if type(i) == dbus.String: settings[str(i)] = str(result[i]) diff --git a/firewallsettings.py b/firewallsettings.py index 6bfea0eb0..0e5a5fc09 100644 --- a/firewallsettings.py +++ b/firewallsettings.py @@ -171,7 +171,7 @@ def _get_fw_data (self, reply_handler=None, error_handler=None): (self, repr(self._fw_data))) if self._fw_data: debugprint ("Using cached firewall data") - if reply_handler == None: + if reply_handler is None: return self._fw_data self._client_reply_handler (self._fw_data) @@ -226,7 +226,7 @@ def write (self): def _check_any_allowed (self, search): (args, filename) = self._get_fw_data () - if filename == None: return True + if filename is None: return True isect = set (search).intersection (set (args)) return len (isect) != 0 @@ -236,7 +236,7 @@ def add_service (self, service): (args, filename) = self._fw_data except AttributeError: (args, filename) = self._get_fw_data () - if filename == None: return + if filename is None: return args.append ("--service=" + service) self._fw_data = (args, filename) diff --git a/gui.py b/gui.py index ba2060651..14af414dd 100644 --- a/gui.py +++ b/gui.py @@ -52,7 +52,7 @@ def getWidgets(self, widgets, domain=None): except AttributeError: win = None - if win != None: + if win is not None: Gtk.Window.set_focus_on_map(widget.get_top_level (), self.focus_on_map) widget.show() diff --git a/install-printerdriver.py b/install-printerdriver.py index 4639f934a..38a89162b 100644 --- a/install-printerdriver.py +++ b/install-printerdriver.py @@ -8,7 +8,7 @@ # http://www.packagekit.org/gtk-doc/PkProgress.html def progress(progress, type, user_data): if (type.value_name == "PK_PROGRESS_TYPE_PERCENTAGE" and - progress.props.package != None): + progress.props.package is not None): sys.stdout.write ("P%d\n" % progress.props.percentage) sys.stdout.flush () else: diff --git a/installpackage.py b/installpackage.py index e806aefab..068b6ca55 100644 --- a/installpackage.py +++ b/installpackage.py @@ -42,18 +42,18 @@ def __init__ (self): def InstallPackageName (self, xid, timestamp, name): try: - if self.iface != None: - self.iface.InstallPackageNames(xid, [name], \ - "hide-finished,show-warnings", \ + if self.iface is not None: + self.iface.InstallPackageNames(xid, [name], + "hide-finished,show-warnings", timeout = 999999) except dbus.exceptions.DBusException: pass def InstallProvideFile (self, xid, timestamp, filename): try: - if self.iface != None: - self.iface.InstallProvideFiles(xid, [filename], \ - "hide-finished,show-warnings", \ + if self.iface is not None: + self.iface.InstallProvideFiles(xid, [filename], + "hide-finished,show-warnings", timeout = 999999) except dbus.exceptions.DBusException: pass diff --git a/jobviewer.py b/jobviewer.py index 547906e9a..3b8abfcce 100644 --- a/jobviewer.py +++ b/jobviewer.py @@ -147,11 +147,11 @@ def lookup_cached_by_name (self, name): def _map_printer (self, uri=None, name=None, connection=None): try: - if connection == None: + if connection is None: connection = cups.Connection () r = ['printer-name', 'printer-uri-supported', 'printer-more-info'] - if uri != None: + if uri is not None: attrs = connection.getPrinterAttributes (uri=uri, requested_attributes=r) else: @@ -166,7 +166,7 @@ def _map_printer (self, uri=None, name=None, connection=None): name = attrs['printer-name'] self.update_from_attrs (name, attrs) - if uri != None: + if uri is not None: self.printer[uri] = name return name @@ -551,7 +551,7 @@ def load_icon(theme, icon): self.statusicon.set_visible (False) # D-Bus - if bus == None: + if bus is None: bus = dbus.SystemBus () self.connect_signals () @@ -643,7 +643,7 @@ def cleanup (self): pass notification.closed = True - if self.job_creation_times_timer != None: + if self.job_creation_times_timer is not None: GLib.source_remove (self.job_creation_times_timer) self.job_creation_times_timer = None @@ -697,7 +697,7 @@ def toggle_window_display(self, icon, force_show=False): if loc: w.set_skip_taskbar_hint (True) - if aw != None: + if aw is not None: aw.set_skip_taskbar_hint (True) self.JobsWindow.iconify () else: @@ -706,7 +706,7 @@ def toggle_window_display(self, icon, force_show=False): self.JobsWindow.present () self.JobsWindow.set_skip_taskbar_hint (False) aw = self.JobsAttributesWindow.get_window() - if aw != None: + if aw is not None: aw.set_skip_taskbar_hint (False) self.JobsWindow.visible = not visible @@ -807,7 +807,7 @@ def add_job (self, job, data, connection=None): self.jobiters[job] = iter range = self.treeview.get_visible_range () - if range != None: + if range is not None: (start, end) = range if (self.store.get_sort_column_id () == (0, Gtk.SortType.DESCENDING) and @@ -842,7 +842,7 @@ def update_job (self, job, data, connection=None): if r: attrs = None try: - if connection == None: + if connection is None: connection = cups.Connection (host=self.host, port=self.port, encryption=self.encryption) @@ -957,12 +957,12 @@ def get_authentication (self, job, device_uri, printer_uri, informational_attrs["domain"] = str (group) else: (serverport, rest) = urllib.parse.splithost (rest) - if serverport == None: + if serverport is None: server = None else: (server, port) = urllib.parse.splitnport (serverport) - if scheme == None or server == None: + if scheme is None or server is None: try_keyring = False else: informational_attrs.update ({ "server": str (server.lower ()), @@ -1022,7 +1022,7 @@ def get_authentication (self, job, device_uri, printer_uri, except RuntimeError: try_keyring = False - if try_keyring and auth_info != None: + if try_keyring and auth_info is not None: try: c._begin_operation (_("authenticating job")) c.authenticateJob (job, auth_info) @@ -1130,7 +1130,7 @@ def auth_info_dialog_response (self, dialog, response): auth_info_required = getattr (dialog, "auth_info_required", None) - if keyring_attrs != None and auth_info_required != None: + if keyring_attrs is not None and auth_info_required is not None: try: ind = auth_info_required.index ('username') keyring_attrs['user'] = auth_info[ind] @@ -1278,7 +1278,7 @@ def update_sensitivity (self, selection = None): except KeyError: uri = None menuitem = Gtk.MenuItem (label=printer) - menuitem.set_sensitive (uri != None) + menuitem.set_sensitive (uri is not None) menuitem.show () self._submenu_connect_hack (menuitem, self.on_job_move_activate, @@ -1325,7 +1325,7 @@ def on_icon_configure_printers_activate(self, menuitem): def poll_subprocess(self, process): returncode = process.poll () - return returncode == None + return returncode is None def on_icon_quit_activate (self, menuitem): self.cleanup () @@ -1460,7 +1460,7 @@ def on_job_retrieve_activate(self, menuitem): format = document.get('document-format', '') # if there's no document-name retrieved - if name == None: + if name is None: # give the default filename some meaningful name name = _("retrieved")+str(document_number) # add extension according to format @@ -1471,7 +1471,7 @@ def on_job_retrieve_activate(self, menuitem): elif format.find('application/') != -1: name = name + format.replace('application/', '.') - if tempfile != None: + if tempfile is not None: dialog = Gtk.FileChooserDialog (title=_("Save File"), transient_for=self.JobsWindow, action=Gtk.FileChooserAction.SAVE) @@ -1603,7 +1603,7 @@ def on_job_attributes_activate(self, menuitem): def update_job_attributes_viewer(self, jobid, conn=None): """ Update attributes store with new values. """ - if conn != None: + if conn is not None: c = conn else: try: @@ -1642,7 +1642,7 @@ def job_is_active (self, jobdata): ## Icon manipulation def add_state_reason_emblem (self, pixbuf, printer=None): worst_reason = None - if printer == None and self.worst_reason != None: + if printer is None and self.worst_reason is not None: # Check that it's valid. printer = self.worst_reason.get_printer () found = False @@ -1650,17 +1650,17 @@ def add_state_reason_emblem (self, pixbuf, printer=None): if reason == self.worst_reason: worst_reason = self.worst_reason break - if worst_reason == None: + if worst_reason is None: self.worst_reason = None - if printer != None: + if printer is not None: for reason in self.printer_state_reasons.get (printer, []): - if worst_reason == None: + if worst_reason is None: worst_reason = reason elif reason > worst_reason: worst_reason = reason - if worst_reason != None: + if worst_reason is not None: level = worst_reason.get_level () if level > StateReason.REPORT: # Add an emblem to the icon. @@ -1687,7 +1687,7 @@ def get_icon_pixbuf (self, have_jobs=None): if not self.applet: return - if have_jobs == None: + if have_jobs is None: have_jobs = len (self.jobs.keys ()) > 0 if have_jobs: @@ -1711,7 +1711,7 @@ def set_statusicon_tooltip (self, tooltip=None): if not self.applet: return - if tooltip == None: + if tooltip is None: num_jobs = len (self.jobs) if num_jobs == 0: tooltip = _("No documents queued") @@ -1756,7 +1756,7 @@ def update_status (self, have_jobs=None): Gdk.threads_enter () self.statusbar.pop (0) - if self.worst_reason != None: + if self.worst_reason is not None: (title, tooltip) = self.worst_reason.get_description () self.statusbar.push (0, tooltip) else: @@ -1860,7 +1860,7 @@ def notify_completed_job (self, jobid): job = self.jobs.get (jobid, {}) document = job.get ('job-name', _("Unknown")) printer_uri = job.get ('job-printer-uri') - if printer_uri != None: + if printer_uri is not None: # Determine if this printer is remote. There's no need to # show a notification if the printer is connected to this # machine. @@ -1869,7 +1869,7 @@ def notify_completed_job (self, jobid): # determined this if authentication was required. device_uri = job.get ('device-uri') - if device_uri == None: + if device_uri is None: pattrs = ['device-uri'] c = authconn.Connection (self.JobsWindow, host=self.host, @@ -1883,7 +1883,7 @@ def notify_completed_job (self, jobid): device_uri = attrs.get ('device-uri') - if device_uri != None: + if device_uri is not None: (scheme, rest) = urllib.parse.splittype (device_uri) if scheme not in ['socket', 'ipp', 'http', 'smb']: return @@ -2228,7 +2228,7 @@ def now_connected (self, mon, printer): except KeyError: debugprint ("Couldn't find state reason (no reasons)!") - if reason != None: + if reason is not None: tuple = reason.get_tuple () else: debugprint ("Couldn't find state reason in list!") @@ -2241,7 +2241,7 @@ def now_connected (self, mon, printer): tuple = (level, p, r) break - if tuple == None: + if tuple is None: debugprint ("Unexpected now_connected signal " "(reason not in notifications list)") return @@ -2334,7 +2334,7 @@ def _find_job_state_text (self, job): elif s == cups.IPP_JOB_HELD: state = _("Held") until = data.get ('job-hold-until') - if until != None: + if until is not None: try: colon1 = until.find (':') if colon1 != -1: @@ -2362,7 +2362,7 @@ def _find_job_state_text (self, job): os.environ["TZ"] = "UTC" simpletime = time.mktime (hold) - if old_tz == None: + if old_tz is None: del os.environ["TZ"] else: os.environ["TZ"] = old_tz @@ -2395,7 +2395,7 @@ def _find_job_state_text (self, job): except KeyError: pass - if state == None: + if state is None: state = _("Unknown") return state diff --git a/monitor.py b/monitor.py index 8deb058cb..620ceefe8 100644 --- a/monitor.py +++ b/monitor.py @@ -140,7 +140,7 @@ def __init__(self, bus=None, my_jobs=True, self.received_any_dbus_signals = False self.update_timer = None - if bus == None: + if bus is None: try: bus = dbus.SystemBus () except dbus.exceptions.DBusException: @@ -148,7 +148,7 @@ def __init__(self, bus=None, my_jobs=True, pass self.bus = bus - if bus != None: + if bus is not None: bus.add_signal_receiver (self.handle_dbus_signal, path=self.DBUS_PATH, dbus_interface=self.DBUS_IFACE) @@ -177,7 +177,7 @@ def cleanup (self): pass cups.setUser (user) - if self.bus != None: + if self.bus is not None: self.bus.remove_signal_receiver (self.handle_dbus_signal, path=self.DBUS_PATH, dbus_interface=self.DBUS_IFACE) @@ -436,7 +436,7 @@ def get_notifications(self): (nse == 'job-state-changed' and jobid not in jobs and event['job-state'] == cups.IPP_JOB_PROCESSING)): - if (self.specific_dests != None and + if (self.specific_dests is not None and event['printer-name'] not in self.specific_dests): continue @@ -471,7 +471,7 @@ def get_notifications(self): except KeyError: continue - if (self.specific_dests != None and + if (self.specific_dests is not None and event['printer-name'] not in self.specific_dests): del jobs[jobid] self.emit ('job-removed', jobid, nse, event) @@ -505,7 +505,7 @@ def refresh(self, which_jobs=None, refresh_all=True): debugprint ("refresh") self.emit ('refresh') - if which_jobs != None: + if which_jobs is not None: self.which_jobs = which_jobs user = cups.getUser () @@ -603,7 +603,7 @@ def refresh(self, which_jobs=None, refresh_all=True): GLib.idle_add (self.emit, 'cups-connection-error') return - if self.specific_dests != None: + if self.specific_dests is not None: for jobid in jobs.keys (): uri = jobs[jobid].get('job-printer-uri', '/') i = uri.rfind ('/') @@ -679,7 +679,7 @@ def fetch_jobs (self, refresh_all): for jobid in range (self.fetch_first_job_id, last_jobid + 1): try: job = fetched[jobid] - if self.specific_dests != None: + if self.specific_dests is not None: uri = job.get('job-printer-uri', '/') i = uri.rfind ('/') printer = uri[i + 1:] @@ -730,7 +730,7 @@ def fetch_jobs (self, refresh_all): return True def sort_jobs_by_printer (self, jobs=None): - if jobs == None: + if jobs is None: jobs = self.jobs my_printers = set() diff --git a/newprinter.py b/newprinter.py index 205db668f..786951e34 100644 --- a/newprinter.py +++ b/newprinter.py @@ -76,7 +76,7 @@ def validDeviceURI (uri): """Returns True is the provided URI is valid.""" (scheme, rest) = urllib.parse.splittype (uri) - if scheme == None or scheme == '': + if scheme is None or scheme == '': return False return True @@ -455,7 +455,7 @@ def __init__(self): def protect_toggle (toggle_widget): active = getattr (toggle_widget, 'protect_active', None) - if active != None: + if active is not None: toggle_widget.set_active (active) for widget in [self.cbNPDownloadableDriverSupplierVendor, @@ -897,7 +897,7 @@ def on_btnNCDelMember_clicked(self, button): def on_tvNCMembers_cursor_changed(self, widget): selection = widget.get_selection() - if selection == None: + if selection is None: return model_from, rows = selection.get_selected_rows() @@ -905,7 +905,7 @@ def on_tvNCMembers_cursor_changed(self, widget): def on_tvNCNotMembers_cursor_changed(self, widget): selection = widget.get_selection() - if selection == None: + if selection is None: return model_from, rows = selection.get_selected_rows() @@ -929,7 +929,7 @@ def on_NPCancel(self, widget, event=None): self.dec_spinner_task () self.NewPrinterWindow.hide() - if self.opreq != None: + if self.opreq is not None: for handler in self.opreq_handlers: self.opreq.disconnect (handler) @@ -1013,7 +1013,7 @@ def do_installdriverpackage(self, name, repo, keyid): done = False pbar = self._installdialog._progress_bar - while self.p.poll() == None: + while self.p.poll() is None: line = stdout.readline ().strip() if (len(line) > 0): if line == "done": @@ -1131,7 +1131,7 @@ def nextNPTab(self, step=1): if fetch_ppd: self.ppd = self.getNPPPD() self.installable_options = False - if self.ppd == None: + if self.ppd is None: return # Prepare Installable Options screen. @@ -1173,7 +1173,7 @@ def nextNPTab(self, step=1): nonfatalException () try: - if name == None and isinstance (self.ppd, cups.PPD): + if name is None and isinstance (self.ppd, cups.PPD): mname = self.ppd.findAttr ("modelName").value make, model = cupshelpers.ppds.ppdMakeModelSplit (mname) if make and model: @@ -1399,7 +1399,7 @@ def _handlePrinterInstallationStage (self, page_nr, step): if not devid: devid = None - if self.ppds == None and self.dialog_mode != "download_driver": + if self.ppds is None and self.dialog_mode != "download_driver": self._loadPPDsForDevice (devid, uri) # _loadPPDsForDevice () is an asynchronous operation, so # let the caller know that it can't continue for now. @@ -1498,9 +1498,9 @@ def _handleDriverInstallation (self): treeview = self.tvNPDownloadableDrivers model, iter = treeview.get_selection ().get_selected () driver = None - if iter != None: + if iter is not None: driver = model.get_value (iter, 1) - if driver == None or driver == 0 or 'packages' not in driver: + if driver is None or driver == 0 or 'packages' not in driver: return # Find the package name, repository, and fingerprint @@ -1800,9 +1800,9 @@ def _installSelectedDriverFromOpenPrinting(self): treeview = self.tvNPDownloadableDrivers model, iter = treeview.get_selection ().get_selected () driver = None - if iter != None: + if iter is not None: driver = model.get_value (iter, 1) - if (driver == None or driver == 0 or 'packages' not in driver): + if (driver is None or driver == 0 or 'packages' not in driver): return # Find the package name, repository, and fingerprint @@ -1870,7 +1870,7 @@ def setNPButtons(self): self.btnNPForward.set_sensitive(bool( (self.rbtnNPFoomatic.get_active() and - self.tvNPMakes.get_cursor()[0] != None) or + self.tvNPMakes.get_cursor()[0] is not None) or self.filechooserPPD.get_filename() or downloadable_selected)) return @@ -1965,7 +1965,7 @@ def _is_driver_license_accepted(self): path, column = treeview.get_cursor() if path: iter = model.get_iter (path) - return (iter != None) + return iter is not None def on_entNPName_changed(self, widget): # restrict @@ -2151,10 +2151,10 @@ def getNetworkPrinterMakeModel(self, host=None, device=None): Returns (hostname or None, uri or None). """ uri = None - if device == None: + if device is None: device = self.device # Determine host name/IP - if host == None: + if host is None: s = device.uri.find ("://") if s != -1: s += 3 @@ -2180,7 +2180,7 @@ def getNetworkPrinterMakeModel(self, host=None, device=None): # Problem executing command. pass - if stdout != None: + if stdout is not None: line = stdout.decode ().strip () words = probe_printer.wordsep (line) n = len (words) @@ -2517,7 +2517,7 @@ class FakeEntry: ready(self.SMBBrowseDialog) - if store.get_iter_first () == None: + if store.get_iter_first () is None: self.SMBBrowseDialog.hide () show_info_dialog (_("No Print Shares"), _("There were no print shares found. " @@ -2534,14 +2534,14 @@ def smb_select_function (self, selection, model, path, path_selected, data): def smbbrowser_cell_share (self, column, cell, model, iter, data): entry = model.get_value (iter, 0) share = '' - if entry != None: + if entry is not None: share = entry.name cell.set_property ('text', share) def smbbrowser_cell_comment (self, column, cell, model, iter, data): entry = model.get_value (iter, 0) comment = '' - if entry != None: + if entry is not None: comment = entry.comment cell.set_property ('text', comment) @@ -2564,7 +2564,7 @@ def on_tvSMBBrowser_row_expanded (self, view, iter, path): """Handler for expanding a row in the SMB tree view.""" model = view.get_model () entry = model.get_value (iter, 0) - if entry == None: + if entry is None: return if entry.smbc_type == pysmb.smbc.WORKGROUP: @@ -2685,7 +2685,7 @@ def on_entSMBURI_changed (self, ent): def on_tvSMBBrowser_cursor_changed(self, widget): selection = self.tvSMBBrowser.get_selection() - if selection == None: + if selection is None: return store, iter = selection.get_selected() @@ -2695,7 +2695,7 @@ def on_tvSMBBrowser_cursor_changed(self, widget): if entry: is_share = entry.smbc_type == pysmb.smbc.PRINTER_SHARE - self.btnSMBBrowseOk.set_sensitive(iter != None and is_share) + self.btnSMBBrowseOk.set_sensitive(iter is not None and is_share) def on_btnSMBBrowse_clicked(self, button): self.btnSMBBrowseOk.set_sensitive(False) @@ -2904,7 +2904,7 @@ def check_firewall (self): # 'Network' not expanded return - if self.firewall != None: + if self.firewall is not None: # Already checked return @@ -2952,7 +2952,7 @@ def device_select_function (self, selection, model, path, *UNUSED): """ model = self.tvNPDevices.get_model () iter = model.get_iter (path) - if model.get_value (iter, 1) != None: + if model.get_value (iter, 1) is not None: return True self.device_row_activated (self.tvNPDevices, path, None) @@ -2968,13 +2968,13 @@ def on_tvNPDevices_cursor_changed(self, widget): self.device_selected += 1 path, column = widget.get_cursor () - if path == None: + if path is None: return model = widget.get_model () iter = model.get_iter (path) physicaldevice = model.get_value (iter, 1) - if physicaldevice == None: + if physicaldevice is None: return show_uris = True for device in physicaldevice.get_devices (): @@ -3043,7 +3043,7 @@ def on_tvNPDevices_cursor_changed(self, widget): protocol = "LPD" elif name.find("._pdl-datastream") != -1: protocol = "AppSocket/JetDirect" - if protocol != None: + if protocol is not None: device.menuentry = (_("%s network printer via DNS-SD") % protocol) else: @@ -3079,10 +3079,10 @@ def on_tvNPDevices_cursor_changed(self, widget): break elif device.type in ["socket", "lpd", "ipp", "dnssd", "mdns"]: # This is a network printer. - if host == None and device.type in ["socket", "lpd", "ipp"]: + if host is None and device.type in ["socket", "lpd", "ipp"]: (scheme, rest) = urllib.parse.splittype (device.uri) (hostport, rest) = urllib.parse.splithost (rest) - if hostport != None: + if hostport is not None: (host, port) = urllib.parse.splitport (hostport) if host: is_network = True @@ -3154,7 +3154,7 @@ def on_tvNPDevices_cursor_changed(self, widget): def on_tvNPDeviceURIs_cursor_changed(self, widget): path, column = widget.get_cursor () - if path == None: + if path is None: return model = widget.get_model () @@ -3202,7 +3202,7 @@ def on_tvNPDeviceURIs_cursor_changed(self, widget): protocol = "LPD" elif name.find("._pdl-datastream") != -1: protocol = "AppSocket/JetDirect" - if protocol != None: + if protocol is not None: text = _("%s network printer via DNS-SD") % protocol else: text = _("Network printer via DNS-SD") @@ -3377,7 +3377,7 @@ def on_btnNetworkFind_clicked(self, button): host = self.entNPTNetworkHostname.get_text () def found_callback (new_device): - if self.printer_finder == None: + if self.printer_finder is None: return GLib.idle_add (self.found_network_printer_callback, new_device) @@ -3532,7 +3532,7 @@ def on_rbtnNPFoomatic_toggled(self, widget): self.cmbNPDownloadableDriverFoundPrinters]: widget.set_sensitive(rbtn3) self.btnNPDownloadableDriverSearch.\ - set_sensitive (rbtn3 and (self.opreq == None)) + set_sensitive (rbtn3 and (self.opreq is None)) self.setNPButtons() @@ -3541,7 +3541,7 @@ def on_filechooserPPD_selection_changed(self, widget): def on_btnNPDownloadableDriverSearch_clicked(self, widget): self.searchedfordriverpackages = True - if self.opreq != None: + if self.opreq is not None: for handler in self.opreq_handlers: self.opreq.disconnect (handler) @@ -3625,7 +3625,7 @@ def opreq_user_search_error (self, opreq, status, err): def on_cmbNPDownloadableDriverFoundPrinters_changed(self, widget): self.setNPButtons () - if self.opreq != None: + if self.opreq is not None: for handler in self.opreq_handlers: self.opreq.disconnect (handler) @@ -3660,7 +3660,7 @@ def fillDownloadableDrivers(self): else: printer_id, printer_str = self.downloadable_printers[0] - if printer_id == None: + if printer_id is None: # If none selected, show all. # This also happens for ID-matching. printer_ids = [x[0] for x in self.downloadable_printers] @@ -3685,7 +3685,7 @@ def fillDownloadableDrivers(self): driver['name']) continue iter = model.append (None) - if first_iter == None: + if first_iter is None: first_iter = iter model.set_value (iter, 0, driver['name']) @@ -3694,7 +3694,7 @@ def fillDownloadableDrivers(self): if driver['recommended']: recommended_iter = iter - if first_iter == None: + if first_iter is None: return False if not self.rbtnNPDownloadableDriverSearch.get_active() and \ @@ -3703,12 +3703,12 @@ def fillDownloadableDrivers(self): model.set_value (iter, 0, _("Local Driver")) model.set_value (iter, 1, 0) - if recommended_iter == None: + if recommended_iter is None: recommended_iter = first_iter treeview = self.tvNPDownloadableDrivers treeview.set_model (model) - if recommended_iter != None: + if recommended_iter is not None: treeview.get_selection ().select_iter (recommended_iter) self.on_tvNPDownloadableDrivers_cursor_changed(treeview) return True @@ -3759,9 +3759,9 @@ def fillMakeList(self): search = devid_dict["DES"] elif devid_dict["MFG"]: search = devid_dict["MFG"] - if search == '' and self.auto_make != None: + if search == '' and self.auto_make is not None: search += self.auto_make - if self.auto_model != None: + if self.auto_model is not None: search += " " + self.auto_model if (search.startswith("Generic") or search.startswith("Unknown")): @@ -3770,7 +3770,7 @@ def fillMakeList(self): def on_tvNPMakes_cursor_changed(self, tvNPMakes): path, column = tvNPMakes.get_cursor() - if path != None and self.ppds != None: + if path is not None and self.ppds is not None: model = tvNPMakes.get_model () iter = model.get_iter (path) self.NPMake = model.get(iter, 1)[0] @@ -3932,7 +3932,7 @@ def on_NPDrivers_query_tooltip(self, tv, x, y, keyboard_mode, tooltip): def on_tvNPModels_cursor_changed(self, widget): path, column = widget.get_cursor() - if path != None: + if path is not None: model = widget.get_model () iter = model.get_iter (path) pmodel = model.get(iter, 1)[0] @@ -3958,7 +3958,7 @@ def on_tvNPDownloadableDrivers_cursor_changed(self, widget): self.frmNPDownloadableDriverLicenseTerms.hide () selection = widget.get_selection () - if selection == None: + if selection is None: return model, iter = selection.get_selected () @@ -4014,7 +4014,7 @@ def set_protect_active (widget, active): except: pass - if value == None: + if value is None: hs.hide () unknown.show_all () @@ -4452,7 +4452,7 @@ def on_signal (*args): n.connect ("printer-added", on_signal) n.connect ("printer-modified", on_signal) n.connect ("dialog-canceled", on_signal) - if setup_printer != None: + if setup_printer is not None: n.init ("printer_with_uri", device_uri=setup_printer, devid=devid) else: n.init ("printer") diff --git a/options.py b/options.py index 1628b112c..85a28983a 100644 --- a/options.py +++ b/options.py @@ -139,12 +139,12 @@ def bool_type (x): self.combobox_map = combobox_map if (type(self.widget) == Gtk.ComboBox and - self.widget.get_model () == None): + self.widget.get_model () is None): print("No ComboBox model for %s" % self.name) model = Gtk.ListStore (str) self.widget.set_model (model) - if combobox_map != None and ipp_type == int: + if combobox_map is not None and ipp_type == int: model = self.widget.get_model () i = 0 dict = {} @@ -170,7 +170,7 @@ def reinit(self, original_value, supported=None): """Set the original value of the option and the supported choices. The special value None for original_value resets the option to the system default.""" - if (supported != None and + if (supported is not None and self.use_supported): if (type(self.widget) == Gtk.ComboBox and self.ipp_type == str): @@ -216,14 +216,14 @@ def reinit(self, original_value, supported=None): self.widget.append_text (text) elif (type(self.widget) == Gtk.ComboBox and self.ipp_type == int and - self.combobox_map != None): + self.combobox_map is not None): model = self.widget.get_model () model.clear () for each in supported: iter = model.append () model.set_value (iter, 0, self.combobox_dict[each]) - if original_value != None: + if original_value is not None: self.original_value = self.ipp_type (original_value) self.set_widget_value (self.original_value) self.button.set_sensitive (True) @@ -239,10 +239,10 @@ def set_widget_value(self, ipp_value): return self.widget.set_value (ipp_value) elif t == Gtk.ComboBox or t == Gtk.ComboBoxText: if ((self.ipp_type == str or self.ipp_type == IPPResolution) - and self.combobox_map == None): + and self.combobox_map is None): model = self.widget.get_model () iter = model.get_iter_first () - while (iter != None and + while (iter is not None and self.ipp_type (model.get_value (iter, 0)) != ipp_value): iter = model.iter_next (iter) if iter: @@ -279,7 +279,7 @@ def get_widget_value(self): return self.ipp_type (self.widget.get_active ()) elif t == Gtk.ComboBoxText: s = self.widget.get_active_text () - if s == None: + if s is None: # If the widget is being re-initialised, there will be # a changed signal emitted at the point where there # are no entries to select from. @@ -297,7 +297,7 @@ def get_current_value(self): return self.get_widget_value () def is_changed(self): - if self.original_value != None: + if self.original_value is not None: # There was a value set previously. if self.state == self.STATE_RESET: # It's been removed. @@ -359,7 +359,7 @@ def hide_special_choice (self): model.remove (model.get_iter_first ()) def reinit(self, original_value, supported=None): - if original_value != None: + if original_value is not None: self.hide_special_choice () else: self.show_special_choice () diff --git a/optionwidgets.py b/optionwidgets.py index 83249800f..dd9f1cd68 100644 --- a/optionwidgets.py +++ b/optionwidgets.py @@ -165,7 +165,7 @@ def on_change(self, widget): def on_btnConflict_clicked(self, button): parent = self.btnConflict - while parent != None and not isinstance (parent, Gtk.Window): + while parent is not None and not isinstance (parent, Gtk.Window): parent = parent.get_parent () dialog = Gtk.MessageDialog (parent=parent, modal=True, destroy_with_parent=True, diff --git a/ppdsloader.py b/ppdsloader.py index c213f5575..7be92eedc 100644 --- a/ppdsloader.py +++ b/ppdsloader.py @@ -74,7 +74,7 @@ def __init__ (self, device_id=None, parent=None, device_uri=None, self._ppdsmatch_result = None self._jockey_queried = False self._jockey_has_answered = False - self._local_cups = (self._host == None or + self._local_cups = (self._host is None or self._host == "localhost" or self._host[0] == '/') try: @@ -196,7 +196,7 @@ def _cups_reply (self, conn, result): conn.destroy () self._conn = None - if self._dialog != None: + if self._dialog is not None: self._dialog.destroy () self._dialog = None @@ -207,7 +207,7 @@ def _cups_error (self, conn, exc): self._conn = None self._ppds = None self._exc = exc - if self._dialog != None: + if self._dialog is not None: self._dialog.destroy () self._dialog = None @@ -273,11 +273,11 @@ def _jockey_error (self, exc): if self._need_requery_cups: self._query_cups () else: - if self._conn != None: + if self._conn is not None: self._conn.destroy () self._conn = None - if self._dialog != None: + if self._dialog is not None: self._dialog.destroy () self._dialog = None @@ -306,7 +306,7 @@ def ppds_loaded (self, ppdsloader): exc = ppdsloader.get_error () print(exc) ppds = ppdsloader.get_ppds () - if ppds != None: + if ppds is not None: print(len (ppds)) ppdsloader.destroy () diff --git a/printerproperties.py b/printerproperties.py index e3718a3d1..9cb29a83b 100755 --- a/printerproperties.py +++ b/printerproperties.py @@ -561,7 +561,7 @@ def show (self, name, host=None, encryption=None, parent=None): if not encryption: self._encryption = cups.getEncryption () - if self._monitor == None: + if self._monitor is None: self.set_monitor (monitor.Monitor (monitor_jobs=False)) self._ppdcache = self._monitor.get_ppdcache () @@ -766,7 +766,7 @@ def on_entPUser_changed(self, widget): def on_tvPUsers_cursor_changed(self, widget): selection = widget.get_selection () - if selection == None: + if selection is None: return model, rows = selection.get_selected_rows() @@ -991,7 +991,7 @@ def setDataButtonState(self): self.btnPrinterPropertiesOK.set_sensitive (not self.conflicts) def save_printer(self, printer, saveall=False, parent=None): - if parent == None: + if parent is None: parent = self.dialog class_deleted = False name = printer.name @@ -1152,7 +1152,7 @@ def on_tvPrinterProperties_selection_changed (self, selection): def on_tvPrinterProperties_cursor_changed (self, treeview): # Adjust notebook to reflect selected item. (path, column) = treeview.get_cursor () - if path != None: + if path is not None: model = treeview.get_model () iter = model.get_iter (path) n = model.get_value (iter, 1) @@ -1218,7 +1218,7 @@ def on_btnPrintTestPage_clicked(self, button): c._end_operation () cups.setUser (user) - if job_id != None: + if job_id is not None: show_info_dialog (_("Submitted"), _("Test page submitted as job %d") % job_id, parent=self.parent) @@ -1263,7 +1263,7 @@ def on_btnCleanHeads_clicked(self, button): self.maintenance_command ("Clean all") def fillComboBox(self, combobox, values, value, translationdict=None): - if translationdict == None: + if translationdict is None: translationdict = ppdippstr.TranslationDict () model = Gtk.ListStore (str, @@ -1572,11 +1572,11 @@ def updateMarkerLevels (self): table.set_row_spacings (12) self.vboxMarkerLevels.pack_start (table, False, False, 0) for color, name, marker_type, level in markers: - if name == None: + if name is None: name = '' elif self.ppd != False: localized_name = self.ppd.localizeMarkerName(name) - if localized_name != None: + if localized_name is not None: name = localized_name row = num_markers / 4 @@ -1849,7 +1849,7 @@ def on_btnClassDelMember_clicked(self, button): def sensitise_new_printer_widgets (self, sensitive=True): sensitive = (sensitive and - self.printer != None and + self.printer is not None and not (self.printer.discovered or bool (self.changed))) for button in [self.btnChangePPD, diff --git a/probe_printer.py b/probe_printer.py index eb4780806..2a9029f02 100644 --- a/probe_printer.py +++ b/probe_printer.py @@ -188,7 +188,7 @@ def probe(self): break found = self.probe_queue(name, result) - if found == None: + if found is None: # Couldn't even connect. break @@ -338,7 +338,7 @@ def _probe_lpd (self): return found = lpd.probe_queue (name, []) - if found == None: + if found is None: # Couldn't even connect. debugprint ("lpd: couldn't connect") break @@ -505,7 +505,7 @@ def _probe_ipp (self): loop = GObject.MainLoop () def display (device): - if device == None: + if device is None: loop.quit () addr = sys.argv[1] diff --git a/scp-dbus-service.py b/scp-dbus-service.py index b7db81289..f0f51efc9 100644 --- a/scp-dbus-service.py +++ b/scp-dbus-service.py @@ -66,7 +66,7 @@ def __init__ (self, cupsconn, language): self._ppds = None def is_ready (self): - return self._ppds != None + return self._ppds is not None def get_ppds (self): return self._ppds @@ -103,7 +103,7 @@ def __init__ (self, device_id, device_make_and_model, device_uri, g_killtimer.add_hold () global g_ppds - if g_ppds == None: + if g_ppds is None: debugprint ("GetBestDrivers request: need to fetch PPDs") g_ppds = FetchedPPDs (self.cupsconn, self.language) self._signals.append (g_ppds.connect ('ready', self._ppds_ready)) @@ -491,7 +491,7 @@ def PrinterPropertiesDialog(self, xid, name): @dbus.service.method(dbus_interface=CONFIG_IFACE, in_signature='', out_signature='s') def JobApplet(self): - if self._jobapplet == None or self._jobapplet.has_finished: + if self._jobapplet is None or self._jobapplet.has_finished: self._pathn += 1 path = "%s/JobApplet/%s" % (CONFIG_PATH, self._pathn) self._jobapplet = ConfigPrintingJobApplet (self.bus, path) diff --git a/statereason.py b/statereason.py index bda44d747..a8846f977 100644 --- a/statereason.py +++ b/statereason.py @@ -52,7 +52,7 @@ def get_printer (self): return self.printer def get_level (self): - if self.level != None: + if self.level is not None: return self.level if (self.reason.endswith ("-report") or @@ -156,7 +156,7 @@ def get_description (self): for scheme in schemes: lreason = self._ppd.localizeIPPReason(self.reason, scheme) - if lreason != None: + if lreason is not None: localized_reason = localized_reason + lreason + ", " if localized_reason != "": reason = localized_reason[:-2] diff --git a/system-config-printer.py b/system-config-printer.py index 349e09226..fdd8d7e03 100755 --- a/system-config-printer.py +++ b/system-config-printer.py @@ -223,7 +223,7 @@ def __init__(self): pass # Maybe cups-pk-helper isn't installed. self.unlock_button = Gtk.LockButton () - if self.edit_permission != None: + if self.edit_permission is not None: self.edit_permission.connect ("notify::allowed", self.polkit_permission_changed) @@ -499,7 +499,7 @@ def __init__(self): def display_properties_dialog_for (self, queue): model = self.dests_iconview.get_model () iter = model.get_iter_first () - while iter != None: + while iter is not None: name = model.get_value (iter, 2) if name == queue: path = model.get_path (iter) @@ -510,7 +510,7 @@ def display_properties_dialog_for (self, queue): break iter = model.iter_next (iter) - if iter == None: + if iter is None: raise RuntimeError def setup_toolbar_for_search_entry (self): @@ -610,7 +610,7 @@ def dests_iconview_selection_changed (self, iconview): userdef = userdefault.UserDefaultPrinter ().get () if (n != 1 or - (userdef == None and self.default_printer == name)): + (userdef is None and self.default_printer == name)): set_default_sensitivity = False else: set_default_sensitivity = True @@ -648,7 +648,7 @@ def dests_iconview_button_press_event (self, iconview, event): click_path = iconview.get_path_at_pos (int (event.x), int (event.y)) paths = iconview.get_selected_items () - if click_path == None: + if click_path is None: iconview.unselect_all () elif click_path not in paths: iconview.unselect_all () @@ -847,19 +847,19 @@ def populateList(self, prompt_allowed=True): if self.current_filter_mode == "filter-name": for name in printers_set.keys (): - if pattern.search (name) != None: + if pattern.search (name) is not None: printers_subset[name] = printers_set[name] elif self.current_filter_mode == "filter-description": for name, printer in printers_set.items (): - if pattern.search (printer.info) != None: + if pattern.search (printer.info) is not None: printers_subset[name] = printers_set[name] elif self.current_filter_mode == "filter-location": for name, printer in printers_set.items (): - if pattern.search (printer.location) != None: + if pattern.search (printer.location) is not None: printers_subset[name] = printers_set[name] elif self.current_filter_mode == "filter-manufacturer": for name, printer in printers_set.items (): - if pattern.search (printer.make_and_model) != None: + if pattern.search (printer.make_and_model) is not None: printers_subset[name] = printers_set[name] else: nonfatalException () @@ -958,7 +958,7 @@ def populateList(self, prompt_allowed=True): except GLib.GError: pass - if pixbuf == None: + if pixbuf is None: try: pixbuf = theme.load_icon ('printer', w, 0) except: @@ -987,7 +987,7 @@ def populateList(self, prompt_allowed=True): continue r = statereason.StateReason (object.name, reason) - if worst_reason == None: + if worst_reason is None: worst_reason = r elif r > worst_reason: worst_reason = r @@ -1256,7 +1256,7 @@ def on_btnCancelConnect_clicked(self, widget): # refresh def on_btnRefresh_clicked(self, button): - if self.cups == None: + if self.cups is None: try: self.cups = authconn.Connection(self.PrintersWindow) except RuntimeError: @@ -1375,11 +1375,11 @@ def rename_confirmed_by_user (self, name): def on_rename_activate(self, *UNUSED): tuple = self.dests_iconview.get_cursor () - if tuple == None: + if tuple is None: return (res, path, cell) = tuple - if path == None: + if path is None: # Printer removed? return @@ -1737,7 +1737,7 @@ def on_shared_activate(self, menuitem): self.cups._end_operation () if success and share: - if self.server_is_publishing == None: + if self.server_is_publishing is None: # We haven't yet seen a server-is-sharing-printers attribute. # Assuming CUPS 1.4, this means we haven't opened a # properties dialog yet. Fetch the attributes now and @@ -1800,7 +1800,7 @@ def on_create_class_activate (self, UNUSED): out_model = self.newPrinterGUI.tvNCNotMembers.get_model () in_model = self.newPrinterGUI.tvNCMembers.get_model () iter = out_model.get_iter_first () - while iter != None: + while iter is not None: next = out_model.iter_next (iter) data = out_model.get (iter, 0) if data[0] in class_members: @@ -1947,7 +1947,7 @@ def on_new_printer_added (self, obj, name): # Now select it. model = self.dests_iconview.get_model () iter = model.get_iter_first () - while iter != None: + while iter is not None: queue = model.get_value (iter, 2) if queue == name: path = model.get_path (iter) @@ -2116,7 +2116,7 @@ def on_printer_modified (self, obj, name, ppd_has_changed): # the new PPD (see bug #441836). try: option = self.propertiesDlg.server_side_options['media'] - if option.get_current_value () == None: + if option.get_current_value () is None: debugprint ("Invalid media option: resetting") option.reset () self.propertiesDlg.changed.add (option) diff --git a/test_PhysicalDevice.py b/test_PhysicalDevice.py index 1af90d93b..bf96f6b22 100644 --- a/test_PhysicalDevice.py +++ b/test_PhysicalDevice.py @@ -26,7 +26,7 @@ except ImportError: cups = None -@pytest.mark.skipif(cups == None, reason="cups module not available") +@pytest.mark.skipif(cups is None, reason="cups module not available") def test_ordering(): # See https://bugzilla.redhat.com/show_bug.cgi?id=1154686 device = cupshelpers.Device("dnssd://Abc%20Def%20%5BABCDEF%5D._ipp._tcp.local/", diff --git a/test_ppds.py b/test_ppds.py index 6fa8909ad..978f16b60 100755 --- a/test_ppds.py +++ b/test_ppds.py @@ -45,7 +45,7 @@ def _singleton (x): return x[0] return x -@pytest.mark.skipif(cups == None, reason="cups module not available") +@pytest.mark.skipif(cups is None, reason="cups module not available") def test_ppds(): picklefile="pickled-ppds" try: @@ -163,7 +163,7 @@ def test_ppds(): match = re.match (modelre, _singleton (ppddict['ppd-make-and-model']), re.I) - success = match != None + success = match is not None else: success = False diff --git a/timedops.py b/timedops.py index 6646a6174..8a7bf4c8d 100644 --- a/timedops.py +++ b/timedops.py @@ -57,7 +57,7 @@ def __init__ (self, timeout=60000, parent=None, show_dialog=True, self.parent = parent self.show_dialog = show_dialog for f in [self.subp.stdout, self.subp.stderr]: - if f != None: + if f is not None: source = GLib.io_add_watch (f, GLib.IO_IN | GLib.IO_HUP | @@ -82,7 +82,7 @@ def run (self): GLib.source_remove (self.wait_source) for source in self.io_source: GLib.source_remove (source) - if self.wait_window != None: + if self.wait_window is not None: self.wait_window.destroy () return (self.output.get (self.subp.stdout, '').split ('\n'), self.output.get (self.subp.stderr, '').split ('\n'), @@ -178,7 +178,7 @@ def __init__ (self, target, args=(), kwargs={}, parent=None, kwargs=kwargs) self.thread.start () - self.use_callback = callback != None + self.use_callback = callback is not None if self.use_callback: self.timeout_source = GLib.timeout_add (50, self._check_thread) @@ -218,8 +218,8 @@ def _check_thread (self): # Thread has finished. Stop the sub-loop or trigger callback. self.timeout_source = False if self.use_callback: - if self.callback != None: - if self.context != None: + if self.callback is not None: + if self.context is not None: self.callback (self.thread.result, self.thread.exception, self.context) else: diff --git a/troubleshoot/CheckNetworkServerSanity.py b/troubleshoot/CheckNetworkServerSanity.py index 5276b988c..c9963473e 100644 --- a/troubleshoot/CheckNetworkServerSanity.py +++ b/troubleshoot/CheckNetworkServerSanity.py @@ -160,7 +160,7 @@ def display (self): (e, s) = e.args self.answers['remote_server_smb_shares'] = (e, s) - if context != None and 'cups_printer_dict' in answers: + if context is not None and 'cups_printer_dict' in answers: uri = answers['cups_printer_dict'].get ('device-uri', '') u = smburi.SMBURI (uri) (group, host, share, user, password) = u.separate () diff --git a/troubleshoot/CheckPPDSanity.py b/troubleshoot/CheckPPDSanity.py index d808926c7..65c5964ba 100644 --- a/troubleshoot/CheckPPDSanity.py +++ b/troubleshoot/CheckPPDSanity.py @@ -120,7 +120,7 @@ def options (options_list): if tmpf: os.unlink (tmpf) - if title == None and not answers['cups_printer_remote']: + if title is None and not answers['cups_printer_remote']: (pkgs, exes) = cupshelpers.missingPackagesAndExecutables (ppd) self.answers['missing_pkgs_and_exes'] = (pkgs, exes) if len (pkgs) > 0 or len (exes) > 0: @@ -142,11 +142,11 @@ def options (options_list): "is not currently installed.") % (name, (exes + pkgs)[0]) - if title != None: + if title is not None: self.label.set_markup ('' + title + '\n\n' + text) - return title != None + return title is not None def connect_signals (self, handle): self.button_sigid = self.install_button.connect ("clicked", diff --git a/troubleshoot/CheckUSBPermissions.py b/troubleshoot/CheckUSBPermissions.py index 73fcf4504..42526b72e 100644 --- a/troubleshoot/CheckUSBPermissions.py +++ b/troubleshoot/CheckUSBPermissions.py @@ -81,7 +81,7 @@ def display (self): dev_by_id = {} this_dev = None for line in lsusb_stdout: - if (this_dev != None and + if (this_dev is not None and ((line.find ("bInterfaceClass") != -1 and line.find ("7 Printer") != -1) or (line.find ("bInterfaceSubClass") != -1 and diff --git a/troubleshoot/ChooseNetworkPrinter.py b/troubleshoot/ChooseNetworkPrinter.py index d925c73f0..49042dca4 100644 --- a/troubleshoot/ChooseNetworkPrinter.py +++ b/troubleshoot/ChooseNetworkPrinter.py @@ -86,15 +86,15 @@ def display (self): printers = None dests_list = [] for (name, instance), dest in dests.items (): - if name == None: + if name is None: continue - if instance != None: + if instance is not None: queue = "%s/%s" % (name, instance) else: queue = name - if printers == None: + if printers is None: self.op = TimedOperation (c.getPrinters) printers = self.op.run () @@ -130,7 +130,7 @@ def disconnect_signals (self): def can_click_forward (self): model, iter = self.treeview.get_selection ().get_selected () - if iter == None: + if iter is None: return False return True diff --git a/troubleshoot/ChoosePrinter.py b/troubleshoot/ChoosePrinter.py index 5adc5af0a..4cb6260eb 100644 --- a/troubleshoot/ChoosePrinter.py +++ b/troubleshoot/ChoosePrinter.py @@ -78,15 +78,15 @@ def display (self): printers = None dests_list = [] for (name, instance), dest in dests.items (): - if name == None: + if name is None: continue - if instance != None: + if instance is not None: queue = "%s/%s" % (name, instance) else: queue = name - if printers == None: + if printers is None: printers = self.timedop (c.getPrinters, parent=parent).run () @@ -122,7 +122,7 @@ def disconnect_signals (self): def can_click_forward (self): model, iter = self.treeview.get_selection ().get_selected () - if iter == None: + if iter is None: return False return True diff --git a/troubleshoot/DeviceListed.py b/troubleshoot/DeviceListed.py index f982b649a..45617bdc0 100644 --- a/troubleshoot/DeviceListed.py +++ b/troubleshoot/DeviceListed.py @@ -133,7 +133,7 @@ def disconnect_signals (self): def can_click_forward (self): model, iter = self.treeview.get_selection ().get_selected () - if iter == None: + if iter is None: return False return True diff --git a/troubleshoot/ErrorLogFetch.py b/troubleshoot/ErrorLogFetch.py index 3296b796f..8eea0615e 100644 --- a/troubleshoot/ErrorLogFetch.py +++ b/troubleshoot/ErrorLogFetch.py @@ -122,7 +122,7 @@ def set_settings (connection, settings): pass self.answers = {} - if journal and cursor != None: + if journal and cursor is not None: def journal_format (x): try: priority = "XACEWNIDd"[x['PRIORITY']] @@ -138,12 +138,12 @@ def journal_format (x): r.add_match (_SYSTEMD_UNIT="cups.service") self.answers['journal'] = [journal_format (x) for x in r] - if checkpoint != None: + if checkpoint is not None: self.op = TimedOperation (fetch_log, (self.authconn,), parent=parent) tmpfname = self.op.run () - if tmpfname != None: + if tmpfname is not None: f = open (tmpfname) f.seek (checkpoint) lines = f.readlines () diff --git a/troubleshoot/Locale.py b/troubleshoot/Locale.py index 6fb214f76..f13f1f1d3 100644 --- a/troubleshoot/Locale.py +++ b/troubleshoot/Locale.py @@ -69,14 +69,14 @@ def display (self): except IOError: continue - if conf != None: + if conf is not None: for line in conf: if line.startswith("LC_PAPER="): system_lang = line[9:].strip ('\n"') - elif system_lang == None and line.startswith ("LANG="): + elif system_lang is None and line.startswith ("LANG="): system_lang = line[5:].strip ('\n"') - if system_lang != None: + if system_lang is not None: dot = system_lang.find ('.') if dot != -1: system_lang = system_lang[:dot] @@ -106,7 +106,7 @@ def display (self): job_status = [] self.answers['printer_page_size'] = printer_page_size - if printer_page_size != None: + if printer_page_size is not None: job_page_size = None for (test, jobid, printer, doc, status, attrs) in job_status: if test: diff --git a/troubleshoot/PrintTestPage.py b/troubleshoot/PrintTestPage.py index 3cae150d8..9e49a4a17 100644 --- a/troubleshoot/PrintTestPage.py +++ b/troubleshoot/PrintTestPage.py @@ -140,7 +140,7 @@ def display (self): mediatype = value break - if mediatype != None: + if mediatype is not None: mediatype_string = '\n\n' + (_("Remember to load paper of type " "'%s' into the printer first.") % mediatype) @@ -313,7 +313,7 @@ def collect_attributes (jobs): attrs = c.getJobAttributes (jobid) except AttributeError: # getJobAttributes was introduced in pycups 1.9.35. - if job_attrs == None: + if job_attrs is None: job_attrs = c.getJobs (which_jobs='all') attrs = self.job_attrs[jobid] @@ -360,7 +360,7 @@ def update_job (self, jobid, job_dict): except KeyError: printer_name = None - if printer_name != None: + if printer_name is not None: model.set_value (iter, 2, printer_name) model.set_value (iter, 3, job_dict['job-name']) @@ -383,7 +383,7 @@ def print_test_page (*args, **kwargs): mimetypes = [None, 'text/plain'] for mimetype in mimetypes: try: - if mimetype == None: + if mimetype is None: # Default test page. self.op = TimedOperation (print_test_page, (answers['cups_queue'],), @@ -421,7 +421,7 @@ def print_test_page (*args, **kwargs): if (e == cups.IPP_DOCUMENT_FORMAT and mimetypes.index (mimetype) < (len (mimetypes) - 1)): # Try next format. - if tmpfname != None: + if tmpfname is not None: os.unlink (tmpfname) tmpfname = None continue diff --git a/userdefault.py b/userdefault.py index f80f9841a..0e8f6e6ae 100644 --- a/userdefault.py +++ b/userdefault.py @@ -140,7 +140,7 @@ def __init__ (self, systemwide.set_active (True) clearpersonal.set_active (True) self.userdef = UserDefaultPrinter () - clearpersonal.set_sensitive (self.userdef.get () != None) + clearpersonal.set_sensitive (self.userdef.get () is not None) self.systemwide = systemwide self.clearpersonal = clearpersonal @@ -150,7 +150,7 @@ def __init__ (self, dialog.show_all () def on_toggled (self, button): - self.clearpersonal.set_sensitive (self.userdef.get () != None and + self.clearpersonal.set_sensitive (self.userdef.get () is not None and self.systemwide.get_active ()) def on_response (self, dialog, response_id): diff --git a/xml/validate.py b/xml/validate.py index 84b55aa9c..8fc201ecf 100644 --- a/xml/validate.py +++ b/xml/validate.py @@ -46,11 +46,11 @@ def validate (self): for printer in preferenceorder.getchildren (): types = [] drivers = printer.find ("drivers") - if drivers != None: + if drivers is not None: types.extend (drivers.getchildren ()) blacklist = printer.find ("blacklist") - if blacklist != None: + if blacklist is not None: types.extend (blacklist.getchildren ()) for drivertype in types: