bin/ui-rules-enforcer.py | 64 +++++++++++++-------------- librelogo/source/LibreLogo/LibreLogo.py | 6 +- scripting/source/pyprov/mailmerge.py | 8 +-- sd/qa/uitest/impress_tests2/tdf133713.py | 2 solenv/bin/native-code.py | 2 solenv/gdb/boost/lib/unordered.py | 4 - solenv/gdb/boost/optional.py | 2 solenv/gdb/boost/ptr_container.py | 4 - solenv/gdb/boost/smart_ptr.py | 2 solenv/gdb/boost/unordered.py | 2 solenv/gdb/libreoffice/sw.py | 2 sw/qa/uitest/writer_tests4/spellDialog.py | 4 - sw/qa/uitest/writer_tests8/tdf106733.py | 4 - sw/qa/uitest/writer_tests8/tdf159102.py | 4 - sw/qa/uitest/writer_tests8/tdf160170.py | 4 - uitest/ui_logger_dsl/dsl_core.py | 2 uitest/uitest/uihelper/testDialog.py | 4 - wizards/com/sun/star/wizards/ui/UnoDialog.py | 2 wizards/source/access2base/access2base.py | 16 +++--- 19 files changed, 69 insertions(+), 69 deletions(-)
New commits: commit 1f8a9bfcdb83446b49e74dba241f9924d3b74748 Author: Julien Nabet <serval2...@yahoo.fr> AuthorDate: Fri Jul 12 15:58:23 2024 +0200 Commit: Julien Nabet <serval2...@yahoo.fr> CommitDate: Sat Jul 13 09:13:54 2024 +0200 Python: use is None/is not None instead of == None/!= None Change-Id: I1c34181897506ad29a063865d752cb85ab76dbc3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170408 Reviewed-by: Julien Nabet <serval2...@yahoo.fr> Tested-by: Jenkins diff --git a/bin/ui-rules-enforcer.py b/bin/ui-rules-enforcer.py index f3514d212276..c363439d25bd 100755 --- a/bin/ui-rules-enforcer.py +++ b/bin/ui-rules-enforcer.py @@ -99,7 +99,7 @@ def replace_button_use_stock(current): if attributes.get("name") == "label": label = child - if isbutton and use_stock != None: + if isbutton and use_stock is not None: do_replace_button_use_stock(current, use_stock, use_underline, label, insertpos) def do_replace_image_stock(current, stock): @@ -166,7 +166,7 @@ def replace_image_stock(current): if attributes.get("name") == "stock": stock = child - if isimage and stock != None: + if isimage and stock is not None: do_replace_image_stock(current, stock) def remove_check_button_align(current): @@ -185,11 +185,11 @@ def remove_check_button_align(current): yalign = child if ischeckorradiobutton: - if xalign != None: + if xalign is not None: if xalign.text != "0": raise Exception(sys.argv[1] + ': non-default xalign', xalign.text) current.remove(xalign) - if yalign != None: + if yalign is not None: if yalign.text != "0.5": raise Exception(sys.argv[1] + ': non-default yalign', yalign.text) current.remove(yalign) @@ -207,7 +207,7 @@ def remove_check_button_relief(current): relief = child if ischeckorradiobutton: - if relief != None: + if relief is not None: current.remove(relief) def remove_check_button_image_position(current): @@ -223,7 +223,7 @@ def remove_check_button_image_position(current): image_position = child if ischeckorradiobutton: - if image_position != None: + if image_position is not None: current.remove(image_position) def remove_spin_button_input_purpose(current): @@ -239,7 +239,7 @@ def remove_spin_button_input_purpose(current): input_purpose = child if isspinbutton: - if input_purpose != None: + if input_purpose is not None: current.remove(input_purpose) def remove_caps_lock_warning(current): @@ -255,7 +255,7 @@ def remove_caps_lock_warning(current): caps_lock_warning = child if iscandidate: - if caps_lock_warning != None: + if caps_lock_warning is not None: current.remove(caps_lock_warning) def remove_spin_button_max_length(current): @@ -271,7 +271,7 @@ def remove_spin_button_max_length(current): max_length = child if isspinbutton: - if max_length != None: + if max_length is not None: current.remove(max_length) def remove_entry_shadow_type(current): @@ -287,7 +287,7 @@ def remove_entry_shadow_type(current): shadow_type = child if isentry: - if shadow_type!= None: + if shadow_typeis not None: current.remove(shadow_type) def remove_label_pad(current): @@ -305,9 +305,9 @@ def remove_label_pad(current): elif attributes.get("name") == "ypad": ypad = child - if xpad != None: + if xpad is not None: current.remove(xpad) - if ypad != None: + if ypad is not None: current.remove(ypad) def remove_label_angle(current): @@ -322,7 +322,7 @@ def remove_label_angle(current): if attributes.get("name") == "angle": angle = child - if angle != None: + if angle is not None: current.remove(angle) def remove_track_visited_links(current): @@ -337,7 +337,7 @@ def remove_track_visited_links(current): if attributes.get("name") == "track_visited_links" or attributes.get("name") == "track-visited-links": track_visited_links = child - if track_visited_links != None: + if track_visited_links is not None: current.remove(track_visited_links) def remove_toolbutton_focus(current): @@ -353,7 +353,7 @@ def remove_toolbutton_focus(current): if attributes.get("name") == "can_focus" or attributes.get("name") == "can-focus": can_focus = child - if can_focus != None: + if can_focus is not None: current.remove(can_focus) def remove_double_buffered(current): @@ -365,7 +365,7 @@ def remove_double_buffered(current): if attributes.get("name") == "double_buffered" or attributes.get("name") == "double-buffered": double_buffered = child - if double_buffered != None: + if double_buffered is not None: current.remove(double_buffered) def remove_label_yalign(current): @@ -377,7 +377,7 @@ def remove_label_yalign(current): if attributes.get("name") == "label_yalign" or attributes.get("name") == "label-yalign": label_yalign = child - if label_yalign != None: + if label_yalign is not None: current.remove(label_yalign) def remove_skip_pager_hint(current): @@ -389,7 +389,7 @@ def remove_skip_pager_hint(current): if attributes.get("name") == "skip_pager_hint" or attributes.get("name") == "skip-pager-hint": skip_pager_hint = child - if skip_pager_hint != None: + if skip_pager_hint is not None: current.remove(skip_pager_hint) def remove_gravity(current): @@ -401,7 +401,7 @@ def remove_gravity(current): if attributes.get("name") == "gravity": gravity = child - if gravity != None: + if gravity is not None: current.remove(gravity) def remove_expander_label_fill(current): @@ -416,7 +416,7 @@ def remove_expander_label_fill(current): if attributes.get("name") == "label_fill" or attributes.get("name") == "label-fill": label_fill = child - if label_fill != None: + if label_fill is not None: current.remove(label_fill) def remove_expander_spacing(current): @@ -431,7 +431,7 @@ def remove_expander_spacing(current): if attributes.get("name") == "spacing": spacing = child - if spacing != None: + if spacing is not None: current.remove(spacing) def enforce_menubutton_indicator_consistency(current): @@ -452,8 +452,8 @@ def enforce_menubutton_indicator_consistency(current): image = child if ismenubutton: - if draw_indicator == None: - if image == None: + if draw_indicator is None: + if image is None: # if there is no draw indicator and no image there should be a draw indicator draw_indicator = etree.Element("property") attributes = draw_indicator.attrib @@ -484,12 +484,12 @@ def enforce_active_in_group_consistency(current): active = child if isradiobutton: - if active != None and active.text != "True": + if active is not None and active.text != "True": raise Exception(sys.argv[1] + ': non-standard active value', active.text) - if group != None and active != None: + if group is not None and active is not None: # if there is a group then we are not the leader and should not be active current.remove(active) - elif group == None and active == None: + elif group is None and active is None: # if there is no group then we are the leader and should be active active = etree.Element("property") attributes = active.attrib @@ -512,7 +512,7 @@ def enforce_toolbar_can_focus(current): can_focus = child if istoolbar: - if can_focus == None: + if can_focus is None: can_focus = etree.Element("property") attributes = can_focus.attrib attributes["name"] = "can-focus" @@ -539,11 +539,11 @@ def enforce_entry_text_column_id_column_for_gtkcombobox(current): idcolumn = child if isgtkcombobox: - if entrytextcolumn != None and entrytextcolumn.text != "0": + if entrytextcolumn is not None and entrytextcolumn.text != "0": raise Exception(sys.argv[1] + ': non-standard entry_text_column value', entrytextcolumn.text) - if idcolumn != None and idcolumn.text != "1": + if idcolumn is not None and idcolumn.text != "1": raise Exception(sys.argv[1] + ': non-standard id_column value', idcolumn.text) - if entrytextcolumn == None: + if entrytextcolumn is None: # if there is no entry_text_column, create one entrytextcolumn = etree.Element("property") attributes = entrytextcolumn.attrib @@ -551,7 +551,7 @@ def enforce_entry_text_column_id_column_for_gtkcombobox(current): entrytextcolumn.text = "0" current.insert(insertpos, entrytextcolumn) insertpos = insertpos + 1 - if idcolumn == None: + if idcolumn is None: # if there is no id_column, create one idcolumn = etree.Element("property") attributes = idcolumn.attrib @@ -577,7 +577,7 @@ def enforce_button_always_show_image(current): image = child if isbutton and image is not None: - if always_show_image == None: + if always_show_image is None: always_show_image = etree.Element("property") attributes = always_show_image.attrib attributes["name"] = "always-show-image" diff --git a/librelogo/source/LibreLogo/LibreLogo.py b/librelogo/source/LibreLogo/LibreLogo.py index 2f29e15732d2..44daaeb00767 100644 --- a/librelogo/source/LibreLogo/LibreLogo.py +++ b/librelogo/source/LibreLogo/LibreLogo.py @@ -610,7 +610,7 @@ class LogoProgram(threading.Thread): # to check LibreLogo program termination (in that case, return value is False) def __is_alive__(): - return __thread__ != None + return __thread__ is not None def __encodestring__(m): __strings__.append(re.sub("(\[^\]|\\(?=[‘’“”»」』]))", "", m.group(2))) @@ -1453,7 +1453,7 @@ def text(shape, orig_st): c.CharFontName = _.fontfamily # has HTML-like formatting - if formatting != None: + if formatting is not None: _.fixSVG = True prev_format = 0 prev_extra_data = extra_data[0] @@ -1603,7 +1603,7 @@ def fillstyle(s): def __splitcolor__(c, shape = None, angle = None): if shape and (type(c) == tuple or type(_.t10y) == list): - angle = heading() if angle == None else -angle / 100 + 360 + angle = heading() if angle is None else -angle / 100 + 360 if type(c) == tuple: shape.FillStyle = __FillStyle_GRADIENT__ # gradient color: [color1, color2, style, angle(must be positive for I/O), border, x_percent, y_percent, color1_intensity_percent, color2_intensity_percent] diff --git a/scripting/source/pyprov/mailmerge.py b/scripting/source/pyprov/mailmerge.py index 46d1c887263c..37421585f3b4 100644 --- a/scripting/source/pyprov/mailmerge.py +++ b/scripting/source/pyprov/mailmerge.py @@ -159,7 +159,7 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): def isConnected(self): if dbg: print("PyMailSMTPService isConnected", file=sys.stderr) - return self.server != None + return self.server is not None def getCurrentConnectionContext(self): if dbg: print("PyMailSMTPService getCurrentConnectionContext", file=sys.stderr) @@ -353,7 +353,7 @@ class PyMailIMAPService(unohelper.Base, XMailService): def isConnected(self): if dbg: print("PyMailIMAPService isConnected", file=sys.stderr) - return self.server != None + return self.server is not None def getCurrentConnectionContext(self): if dbg: print("PyMailIMAPService getCurrentConnectionContext", file=sys.stderr) @@ -430,7 +430,7 @@ class PyMailPOP3Service(unohelper.Base, XMailService): def isConnected(self): if dbg: print("PyMailPOP3Service isConnected", file=sys.stderr) - return self.server != None + return self.server is not None def getCurrentConnectionContext(self): if dbg: print("PyMailPOP3Service getCurrentConnectionContext", file=sys.stderr) @@ -472,7 +472,7 @@ class PyMailMessage(unohelper.Base, XMailMessage): self.ccrecipients = [] self.bccrecipients = [] self.aMailAttachments = [] - if aMailAttachment != None: + if aMailAttachment is not None: self.aMailAttachments.append(aMailAttachment) self.SenderName, self.SenderAddress = parseaddr(sFrom) diff --git a/sd/qa/uitest/impress_tests2/tdf133713.py b/sd/qa/uitest/impress_tests2/tdf133713.py index da84ae94fbeb..09a174358147 100644 --- a/sd/qa/uitest/impress_tests2/tdf133713.py +++ b/sd/qa/uitest/impress_tests2/tdf133713.py @@ -51,7 +51,7 @@ class Tdf133713(UITestCase): xEnumeration = shape.Text.createEnumeration() # Without the fix in place, this test would have failed with - # AssertionError: 0 != None + # AssertionError: 0 is not None for i in range(3): self.assertEqual(0, xEnumeration.nextElement().NumberingLevel) diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index 26de5c199ec1..743d8bfb5a8e 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -782,7 +782,7 @@ def limit_rdb(services_rdb, full_factory_map, full_constructor_map): # direct uri = component.get('uri') component_name = None - if uri != None: + if uri is not None: component_name = re.sub(r'^vnd.sun.star.expand:\$LO_LIB_DIR/([^.]*).so$', r'.a', uri) if component_name in full_factory_map: continue diff --git a/solenv/gdb/boost/lib/unordered.py b/solenv/gdb/boost/lib/unordered.py index ee58d0481158..0182a1603265 100644 --- a/solenv/gdb/boost/lib/unordered.py +++ b/solenv/gdb/boost/lib/unordered.py @@ -55,7 +55,7 @@ class Unordered(object): hash_buckets = hash_table.type.fields()[0] assert hash_buckets.is_base_class node_type = gdb.lookup_type("%s::node" % hash_buckets.type) - assert node_type != None + assert node_type is not None return node_type class _iterator(six.Iterator): @@ -91,7 +91,7 @@ class Unordered(object): def _value(self): assert self.node != self.bucket # bucket node has no value - assert self.node != None + assert self.node is not None node = self.node.dereference().cast(self.node_type) return node['data_'].cast(self.value_type) diff --git a/solenv/gdb/boost/optional.py b/solenv/gdb/boost/optional.py index 08297254efc0..d32c272a70a2 100644 --- a/solenv/gdb/boost/optional.py +++ b/solenv/gdb/boost/optional.py @@ -41,7 +41,7 @@ printer = None def build_pretty_printers(): global printer - if printer != None: + if printer is not None: return printer = printing.Printer("boost.optional") diff --git a/solenv/gdb/boost/ptr_container.py b/solenv/gdb/boost/ptr_container.py index 425d812f54b5..9b61268302cf 100644 --- a/solenv/gdb/boost/ptr_container.py +++ b/solenv/gdb/boost/ptr_container.py @@ -48,7 +48,7 @@ class PtrStdPrinterBase(object): self.sequence = None def to_string(self): - if self.sequence != None: + if self.sequence is not None: length = len(self.sequence) if length: return "%s %s" % (self.typename, self.print_size(length)) @@ -223,7 +223,7 @@ printer = None def build_pretty_printers(): global printer - if printer != None: + if printer is not None: return printer = printing.Printer("boost.ptr_container") diff --git a/solenv/gdb/boost/smart_ptr.py b/solenv/gdb/boost/smart_ptr.py index 60d88278a5ac..3e97c57d4fef 100644 --- a/solenv/gdb/boost/smart_ptr.py +++ b/solenv/gdb/boost/smart_ptr.py @@ -57,7 +57,7 @@ printer = None def build_pretty_printers(): global printer - if printer != None: + if printer is not None: return printer = printing.Printer("boost.smart_ptr") diff --git a/solenv/gdb/boost/unordered.py b/solenv/gdb/boost/unordered.py index 2c56721857b8..1348ce9bbec7 100644 --- a/solenv/gdb/boost/unordered.py +++ b/solenv/gdb/boost/unordered.py @@ -94,7 +94,7 @@ printer = None def build_pretty_printers(): global printer - if printer != None: + if printer is not None: return printer = printing.Printer("boost.unordered") diff --git a/solenv/gdb/libreoffice/sw.py b/solenv/gdb/libreoffice/sw.py index 50d0f2221f2e..89ac80e5eb2a 100644 --- a/solenv/gdb/libreoffice/sw.py +++ b/solenv/gdb/libreoffice/sw.py @@ -284,7 +284,7 @@ class BigPtrArrayPrinter(object): assert self.pos <= self.count assert self.block_pos <= self.block_count if self.pos == 0 and self.pos < self.count: - assert self.block != None + assert self.block is not None printer = None diff --git a/sw/qa/uitest/writer_tests4/spellDialog.py b/sw/qa/uitest/writer_tests4/spellDialog.py index 91be3cc3a948..17898c4dc5b7 100644 --- a/sw/qa/uitest/writer_tests4/spellDialog.py +++ b/sw/qa/uitest/writer_tests4/spellDialog.py @@ -22,11 +22,11 @@ class SpellingAndGrammarDialog(UITestCase): xSpellChecker = get_spellchecker(self.ui_test._xContext) locales = xSpellChecker.getLocales() for locale in locales: - if language != None: + if language is not None: if locale.Language != language: continue - if country != None: + if country is not None: if locale.Country != country: continue diff --git a/sw/qa/uitest/writer_tests8/tdf106733.py b/sw/qa/uitest/writer_tests8/tdf106733.py index 697a1b6dcda1..9e3b298d2739 100644 --- a/sw/qa/uitest/writer_tests8/tdf106733.py +++ b/sw/qa/uitest/writer_tests8/tdf106733.py @@ -20,11 +20,11 @@ class tdf106733(UITestCase): xHyphenator = xLinguServiceManager.getHyphenator() locales = xHyphenator.getLocales() for locale in locales: - if language != None: + if language is not None: if locale.Language != language: continue - if country != None: + if country is not None: if locale.Country != country: continue diff --git a/sw/qa/uitest/writer_tests8/tdf159102.py b/sw/qa/uitest/writer_tests8/tdf159102.py index e5e50dd6f698..c4ece7f725fe 100644 --- a/sw/qa/uitest/writer_tests8/tdf159102.py +++ b/sw/qa/uitest/writer_tests8/tdf159102.py @@ -19,11 +19,11 @@ class tdf159102(UITestCase): xHyphenator = xLinguServiceManager.getHyphenator() locales = xHyphenator.getLocales() for locale in locales: - if language != None: + if language is not None: if locale.Language != language: continue - if country != None: + if country is not None: if locale.Country != country: continue diff --git a/sw/qa/uitest/writer_tests8/tdf160170.py b/sw/qa/uitest/writer_tests8/tdf160170.py index 69ead0d5b52e..e90a6660c738 100644 --- a/sw/qa/uitest/writer_tests8/tdf160170.py +++ b/sw/qa/uitest/writer_tests8/tdf160170.py @@ -19,11 +19,11 @@ class tdf160170(UITestCase): xHyphenator = xLinguServiceManager.getHyphenator() locales = xHyphenator.getLocales() for locale in locales: - if language != None: + if language is not None: if locale.Language != language: continue - if country != None: + if country is not None: if locale.Country != country: continue diff --git a/uitest/ui_logger_dsl/dsl_core.py b/uitest/ui_logger_dsl/dsl_core.py index 798dc43256e9..79bd748b54e2 100644 --- a/uitest/ui_logger_dsl/dsl_core.py +++ b/uitest/ui_logger_dsl/dsl_core.py @@ -254,7 +254,7 @@ class ul_Compiler: self.variables.append(line) def handle_uno(self, UNOCommand): - if UNOCommand.parameters == None: + if UNOCommand.parameters is None: line = ( tab * 3 + 'self.xUITest.executeCommand("' diff --git a/uitest/uitest/uihelper/testDialog.py b/uitest/uitest/uihelper/testDialog.py index d5691522f3c0..20d37205d5a2 100644 --- a/uitest/uitest/uihelper/testDialog.py +++ b/uitest/uitest/uihelper/testDialog.py @@ -26,7 +26,7 @@ def testAppDialog(UITestCase, app, dialog): except: xOKBtn = None - if (xOKBtn != None): + if (xOKBtn is not None): print("check also OK button") with UITestCase.ui_test.execute_dialog_through_command(dialog['command']): pass @@ -57,7 +57,7 @@ def testChartDialog(UITestCase, dialog): except: xOKBtn = None - if (xOKBtn != None): + if (xOKBtn is not None): print("check also OK button") with UITestCase.ui_test.execute_dialog_through_action( xObj, "COMMAND", diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog.py b/wizards/com/sun/star/wizards/ui/UnoDialog.py index 5def1b184c40..cb320693f74d 100644 --- a/wizards/com/sun/star/wizards/ui/UnoDialog.py +++ b/wizards/com/sun/star/wizards/ui/UnoDialog.py @@ -106,7 +106,7 @@ class UnoDialog(object): def setVisible(self, parent): self.calculateDialogPosition(parent.xUnoDialog.getPosSize()) - if self.xWindowPeer == None: + if self.xWindowPeer is None: self.createWindowPeer() self.xUnoDialog.setVisible(True) diff --git a/wizards/source/access2base/access2base.py b/wizards/source/access2base/access2base.py index 2410e6d88dae..ee1e05f17324 100644 --- a/wizards/source/access2base/access2base.py +++ b/wizards/source/access2base/access2base.py @@ -574,12 +574,12 @@ class _A2B(object, metaclass = _Singleton): # Check the availability of the Access2Base library for lib in ('Access2BaseDev', 'Access2Base'): try: - if Script == None: + if Script is None: Script = SCRIPTPROVIDER.getScript(sScript(lib)) _LIBRARY = lib except Exception: pass - if Script == None: + if Script is None: raise SystemExit('Access2Base basic library not found') else: Script = SCRIPTPROVIDER.getScript(sScript(_LIBRARY)) @@ -607,14 +607,14 @@ class _A2B(object, metaclass = _Singleton): :param args: list of arguments to be passed to the script :return: the value returned by the script execution """ - if COMPONENTCONTEXT == None: A2BConnect() # Connection from inside LibreOffice is done at first API invocation + if COMPONENTCONTEXT is None: A2BConnect() # Connection from inside LibreOffice is done at first API invocation Script = cls.xScript(script, module) try: Returned = Script.invoke((args), (), ())[0] except Exception: raise TypeError("Access2Base error: method '" + script + "' in Basic module '" + module + "' call error. Check its arguments.") else: - if Returned == None: + if Returned is None: if cls.VerifyNoError(): return None return Returned @@ -632,7 +632,7 @@ class _A2B(object, metaclass = _Singleton): :param args: the arguments of the method, if any :return: the value returned by the execution of the Basic routine """ - if COMPONENTCONTEXT == None: A2BConnect() # Connection from inside LibreOffice is done at first API invocation + if COMPONENTCONTEXT is None: A2BConnect() # Connection from inside LibreOffice is done at first API invocation # Intercept special call to Application.Events() if basic == Application.basicmodule and script == 'Events': Script = cls.xScript('PythonEventsWrapper', _WRAPPERMODULE) @@ -666,7 +666,7 @@ class _A2B(object, metaclass = _Singleton): return None else: # UNO object return Returned[0] - elif Returned[0] == None: + elif Returned[0] is None: if cls.VerifyNoError(): return None else: # Should not happen return Returned[0] @@ -756,8 +756,8 @@ class Application(object, metaclass = _Singleton): @classmethod def OpenConnection(cls, thisdatabasedocument = acConstants.Missing): global THISDATABASEDOCUMENT - if COMPONENTCONTEXT == None: A2BConnect() # Connection from inside LibreOffice is done at first API invocation - if DESKTOP != None: + if COMPONENTCONTEXT is None: A2BConnect() # Connection from inside LibreOffice is done at first API invocation + if DESKTOP is not None: THISDATABASEDOCUMENT = DESKTOP.getCurrentComponent() return _A2B.invokeMethod('OpenConnection', 'Application', THISDATABASEDOCUMENT) @classmethod