build-analysis/parse-scp2.py |   26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

New commits:
commit dbc32eae23589e552ecf2ff5bf2dad7a51402e6f
Author:     Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
AuthorDate: Fri Jul 12 12:48:15 2024 +0300
Commit:     Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
CommitDate: Fri Jul 12 11:49:41 2024 +0200

    build-analysis: fix issues found by Ruff linter
    
    Change-Id: I7e789704ff294e533c388653f86d03e6a8646e78
    Reviewed-on: https://gerrit.libreoffice.org/c/dev-tools/+/170401
    Tested-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
    Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>

diff --git a/build-analysis/parse-scp2.py b/build-analysis/parse-scp2.py
index 98b1b9c4..a0071812 100755
--- a/build-analysis/parse-scp2.py
+++ b/build-analysis/parse-scp2.py
@@ -26,7 +26,11 @@
 #
 ########################################################################
 
-import sys, os, os.path, optparse, subprocess
+import sys
+import os
+import os.path
+import optparse
+import subprocess
 
 arg_desc = ""
 
@@ -287,7 +291,7 @@ class Scp2Parser(object):
             nodetree[name] = LinkedNode(name)
 
         nodetree[parentID].children.append(nodetree[name])
-        if nodetree[name].parent != None:
+        if nodetree[name].parent is not None:
             raise ParseError("parent node instance already exists for 
'%s'"%name, 1)
         nodetree[name].parent = nodetree[parentID]
 
@@ -314,7 +318,7 @@ class Scp2Parser(object):
                 nodetree[parentID] = LinkedNode(parentID)
 
             nodetree[parentID].children.append(nodetree[name])
-            if nodetree[name].parent != None:
+            if nodetree[name].parent is not None:
                 raise ParseError("parent node instance already exists for 
'%s'"%name, 1)
             nodetree[name].parent = nodetree[parentID]
 
@@ -400,7 +404,7 @@ class XMLFunc:
         """CamelCase to camel-case"""
         s = ''
         n = len(name)
-        for i in xrange(0, n):
+        for i in range(0, n):
             c = name[i]
             if 'A' <= c and c <= 'Z':
                 if i > 0:
@@ -581,7 +585,7 @@ class Scp2Processor(object):
 
         parent_dir_name = nodedata['Dir']
 
-        while parent_dir_name != None:
+        while parent_dir_name is not None:
 
             if parent_dir_name == 'PREDEFINED_PROGDIR':
                 # special directory name
@@ -613,7 +617,7 @@ class Scp2Processor(object):
 
         indent = '    '*level
 
-        if node == None:
+        if node is None:
             return
 
         if not self.nodedata.has_key(node.name):
@@ -709,7 +713,7 @@ class OOLstParser(object):
             keys.sort()
             for key in keys:
                 s += "    %s"%key
-                if attrs[key] != None:
+                if attrs[key] is not None:
                     s += " = %s"%attrs[key]
                 else:
                     s += " ="
@@ -733,7 +737,7 @@ class OOLstParser(object):
         self.ns = [] # namespace stack
         n = len(lines)
         self.last = None
-        for i in xrange(0, n):
+        for i in range(0, n):
             words = lines[i].split()
             if len(words) == 0:
                 # empty line
@@ -743,7 +747,7 @@ class OOLstParser(object):
                 # new scope begins
                 if len(words) != 1:
                     raise _Error("{ is followed by a token.", 1)
-                if self.last == None:
+                if self.last is None:
                     raise _Error("fail to find a namespace token in the 
previous line.", 1)
                 if len(self.last) != 1:
                     raise _Error("line contains multiple tokens when only one 
token is expected.", 1)
@@ -765,7 +769,7 @@ class OOLstParser(object):
             self.last = words
 
     def __check_last_line (self):
-        if self.last == None or len(self.last) == 0:
+        if self.last is None or len(self.last) == 0:
             return
 
         if self.last[0] in '{}':
@@ -808,7 +812,7 @@ if __name__ == '__main__':
 
     options, args = parser.parse_args()
 
-    if not options.mode in ['tree', 'flat']:
+    if options.mode not in ['tree', 'flat']:
         error("unknown output mode '%s'"%options.mode)
         sys.exit(1)
 

Reply via email to