Skip to content

Commit 52e159e

Browse files
committed
Correcting python scripts in respect to style
Based om the comment with the issue doxygen#11373, mentioning the `ruff` checker for python, adjusted the used python scripts where necessary and possible.
1 parent b9ac9e4 commit 52e159e

File tree

11 files changed

+87
-84
lines changed

11 files changed

+87
-84
lines changed

addon/doxmlparser/examples/metrics/metrics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def __init__(self):
3636
def print(self):
3737
numMethods = self.numPubMethods + self.numProMethods + self.numPriMethods
3838
numDocMethods = self.numDocPubMethods + self.numDocProMethods + self.numDocPriMethods
39-
print("Metrics:");
40-
print("-----------------------------------");
39+
print("Metrics:")
40+
print("-----------------------------------")
4141
if self.numClasses>0:
4242
print("Classes: {:=10} ({} documented)".format(self.numClasses,self.numDocClasses))
4343
if self.numStructs>0:
@@ -70,12 +70,12 @@ def print(self):
7070
print("Variables: {:=10} ({} documented)".format(self.numVariables,self.numDocVariables))
7171
if self.numParams>0:
7272
print("Params: {:=10}".format(self.numParams))
73-
print("-----------------------------------");
73+
print("-----------------------------------")
7474
if self.numClasses>0:
7575
print("Avg. #methods/compound: {:=10}".format(float(numMethods)/float(self.numClasses)))
7676
if numMethods>0:
7777
print("Avg. #params/method: {:=10}".format(float(self.numParams)/float(numMethods)))
78-
print("-----------------------------------");
78+
print("-----------------------------------")
7979

8080

8181
def description_is_empty(description):

addon/doxmlparser/generateDS_post.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
def main():
1818
inputFile = open(sys.argv[1], 'r')
1919
outputFile = open(sys.argv[2], 'wb')
20-
lineStr = ""
2120
for line in inputFile:
2221
line = line.rstrip()
2322
line = re.sub(r'##','# #',line)

addon/doxypysql/search.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def re_fn(expr, item):
4949
return reg.search(item) is not None
5050

5151
def openDb(dbname):
52-
if dbname == None:
52+
if dbname is None:
5353
dbname = "doxygen_sqlite3.db"
5454

5555
if not os.path.isfile(dbname):
@@ -71,7 +71,7 @@ def match(self,row):
7171
if self.row_type is int:
7272
return " rowid=?"
7373
else:
74-
if g_use_regexp == True:
74+
if g_use_regexp:
7575
return " REGEXP (?,%s)" %row
7676
else:
7777
return " %s=?" %row
@@ -380,7 +380,7 @@ def serveCli(argv):
380380

381381
cn=openDb(dbname)
382382
f=Finder(cn,o)
383-
if ref != None:
383+
if ref is not None:
384384
j=processHref(cn,ref)
385385
else:
386386
j=process(f,kind)

doc/translator.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
from __future__ import print_function
7171

7272
import os
73-
import platform
7473
import re
7574
import sys
7675
import textwrap
@@ -487,7 +486,7 @@ def __collectClassInfo(self, tokenIterator):
487486
self.status = '0.0.00'
488487

489488
# Check whether status was set, or set 'strange'.
490-
if self.status == None:
489+
if self.status is None:
491490
self.status = 'strange'
492491
if not self.readableStatus:
493492
self.readableStatus = 'strange'
@@ -765,7 +764,7 @@ def __collectPublicMethodPrototypes(self, tokenIterator):
765764
the source file."""
766765

767766
assert(self.classId != 'Translator')
768-
assert self.baseClassId != None, 'Class ' + self.classId + ' from the file ' + self.fname + ' does not have a base class.'
767+
assert self.baseClassId is not None, 'Class ' + self.classId + ' from the file ' + self.fname + ' does not have a base class.'
769768

770769
# The following finite automaton slightly differs from the one
771770
# inside self.collectPureVirtualPrototypes(). It produces the
@@ -782,7 +781,6 @@ def __collectPublicMethodPrototypes(self, tokenIterator):
782781
# identifiers.
783782
prototype = '' # readable prototype (with everything)
784783
uniPrototype = '' # unified prototype (without arg. identifiers)
785-
warning = '' # warning message -- if something special detected
786784
methodId = None # processed method id
787785

788786
# Collect the method prototypes. Stop on the closing
@@ -1097,7 +1095,7 @@ def processing(self):
10971095
# Eat the rest of the source to cause closing the file.
10981096
while True:
10991097
try:
1100-
t = next(tokenIterator)
1098+
next(tokenIterator)
11011099
except StopIteration:
11021100
break
11031101

@@ -1414,7 +1412,8 @@ def __extractProcessedInfo(self):
14141412
# of the list.
14151413
langReadableLst = []
14161414
for name, obj in self.langLst:
1417-
if obj.status == 'En': continue
1415+
if obj.status == 'En':
1416+
continue
14181417

14191418
# Append the 'En' to the classId to possibly obtain the classId
14201419
# of the English-based object. If the object exists, modify the
@@ -1665,7 +1664,8 @@ def generateTranslatorReport(self):
16651664
f.write(' %-6s' % obj.readableStatus)
16661665
numimpl = len(obj.missingMethods)
16671666
pluralS = ''
1668-
if numimpl > 1: pluralS = 's'
1667+
if numimpl > 1:
1668+
pluralS = 's'
16691669
percent = 100 * numimpl / numRequired
16701670
f.write('\t%2d method%s to implement (%d %%)' % (
16711671
numimpl, pluralS, percent))
@@ -1693,7 +1693,8 @@ def generateTranslatorReport(self):
16931693
lst.sort()
16941694
plural = len(lst) > 1
16951695
note = 'Note: The adapter class'
1696-
if plural: note += 'es'
1696+
if plural:
1697+
note += 'es'
16971698
note += ' ' + ', '.join(lst)
16981699
if not plural:
16991700
note += ' is'
@@ -1777,7 +1778,6 @@ def __loadMaintainers(self):
17771778
inside = False # inside the record for the language
17781779
lineReady = True
17791780
classId = None
1780-
maintainersLst = None
17811781
self.__maintainersDic = {}
17821782
while lineReady:
17831783
line = f.readline() # next line
@@ -1787,14 +1787,13 @@ def __loadMaintainers(self):
17871787
if line != '' and line[0] == '%': # skip the comment line
17881788
continue
17891789

1790-
if not inside: # if outside of the record
1790+
if not inside: # if outside of the record
17911791
if line != '': # should be language identifier
17921792
classId = line
1793-
maintainersLst = []
17941793
inside = True
17951794
# Otherwise skip empty line that do not act as separator.
17961795

1797-
else: # if inside the record
1796+
else: # if inside the record
17981797
if line == '': # separator found
17991798
inside = False
18001799
else:

doc_internal/cmds_tags.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env python
22

33
from __future__ import print_function
4-
import argparse, glob, itertools, re, shutil, os, sys
4+
import re
5+
import os
6+
import sys
57
import subprocess
68
import shlex
79

@@ -70,7 +72,7 @@ def get_commands(version):
7072
if cmds_reg.match(line):
7173
lst_list.append(re.sub(cmds_reg,'',line).replace("\\\\","\\"))
7274
elif line.startswith("\\endsecreflist"):
73-
break;
75+
break
7476
return lst_list
7577

7678

@@ -80,13 +82,13 @@ def process_commands(old_version,new_version):
8082
old_list = get_commands(old_version)
8183
new_list = get_commands(new_version)
8284
hits = []
83-
for l in new_list:
85+
for n in new_list:
8486
toadd = True
8587
for o in old_list:
86-
if l == o:
88+
if n == o:
8789
toadd = False
8890
if toadd:
89-
hits.append(l)
91+
hits.append(n)
9092

9193
cmds = ""
9294
first = True
@@ -121,21 +123,21 @@ def process_tags(old_version,new_version):
121123
(new_active,new_obsolete) = get_tags(new_version)
122124
hits_active = []
123125
hits_obsolete = []
124-
for l in new_active:
126+
for n in new_active:
125127
toadd = True
126128
for o in old_active:
127-
if l == o:
129+
if n == o:
128130
toadd = False
129131
if toadd:
130-
hits_active.append(l)
132+
hits_active.append(n)
131133

132-
for l in new_obsolete:
134+
for n in new_obsolete:
133135
toadd = True
134136
for o in old_obsolete:
135-
if l == o:
137+
if n == o:
136138
toadd = False
137139
if toadd:
138-
hits_obsolete.append(l)
140+
hits_obsolete.append(n)
139141

140142
tags= ""
141143
if len(hits_active) != 0:

src/caseconvert.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,32 @@ def writePunctuationCodes(file):
4545
{
4646
switch(code)
4747
{
48-
''');
49-
writeMapping(file,toupper);
50-
file.write(r''' default: return nullptr;
48+
''')
49+
writeMapping(file,toupper)
50+
file.write(r''' default: return nullptr
5151
}
5252
}
5353
5454
inline const char *convertUnicodeToLower(uint32_t code)
5555
{
5656
switch(code)
5757
{
58-
''');
59-
writeMapping(file,tolower);
60-
file.write(r''' default: return nullptr;
58+
''')
59+
writeMapping(file,tolower)
60+
file.write(r''' default: return nullptr
6161
}
6262
}
6363
6464
inline bool isPunctuationCharacter(uint32_t code)
6565
{
6666
switch(code)
6767
{
68-
''');
69-
writePunctuationCodes(file);
70-
file.write(r''' default: return false;
68+
''')
69+
writePunctuationCodes(file)
70+
file.write(r''' default: return false
7171
}
72-
return false;
72+
return false
7373
}
7474
7575
#endif
76-
''');
76+
''')

0 commit comments

Comments
 (0)