Skip to content

Commit d4a0f2a

Browse files
committed
Fix several pylint warnings
This fixes some pylint warnings such as unused variables or imports, and suppresses a few others (unused imports in test scripts).
1 parent 17f3db9 commit d4a0f2a

File tree

7 files changed

+21
-23
lines changed

7 files changed

+21
-23
lines changed

commands/preprocess.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def find_files_to_be_renamed(root):
116116
# consistent and short file names because we
117117
# modify some of them later in the pipeline
118118

119-
for dir, dirnames, filenames in os.walk(root):
119+
for dir, _, filenames in os.walk(root):
120120
filenames_loader = set(fnmatch.filter(filenames, 'load.php[?]*'))
121121
# match any filenames with '?"*' characters
122122
filenames_rename = set(fnmatch.filter(filenames, '*[?"*]*'))
@@ -129,15 +129,15 @@ def find_files_to_be_renamed(root):
129129
for fn in filenames_rename:
130130
files_rename.append((dir, fn))
131131

132-
for dir,orig_fn in files_rename:
132+
for dir, orig_fn in files_rename:
133133
fn = orig_fn
134134
fn = re.sub(r'\?.*', '', fn)
135135
fn = fn.replace('"', '_q_')
136136
fn = fn.replace('*', '_star_')
137137
add_file_to_rename_map(rename_map, dir, orig_fn, fn)
138138

139139
# map loader names to more recognizable names
140-
for dir,fn in files_loader:
140+
for dir, fn in files_loader:
141141
new_fn = convert_loader_name(fn)
142142
add_file_to_rename_map(rename_map, dir, fn, new_fn)
143143

@@ -157,7 +157,7 @@ def rename_files(rename_map):
157157
def find_html_files(root):
158158
# find files that need to be preprocessed
159159
html_files = []
160-
for dir, dirnames, filenames in os.walk(root):
160+
for dir, _, filenames in os.walk(root):
161161
for filename in fnmatch.filter(filenames, '*.html'):
162162
html_files.append(os.path.join(dir, filename))
163163
return html_files
@@ -210,7 +210,7 @@ def is_external_link(target):
210210

211211
def trasform_relative_link(rename_map, target):
212212
target = urllib.parse.unquote(target)
213-
for dir,fn,new_fn in rename_map:
213+
for _, fn, new_fn in rename_map:
214214
target = target.replace(fn, new_fn)
215215
target = target.replace('../../upload.cppreference.com/mwiki/','../common/')
216216
target = target.replace('../mwiki/','../common/')

preprocess.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# You should have received a copy of the GNU General Public License
1818
# along with this program. If not, see http://www.gnu.org/licenses/.
1919

20-
from commands.preprocess import *
20+
from commands import preprocess
2121
import argparse
2222
import os
2323
import shutil
@@ -32,17 +32,17 @@ def main():
3232
src = args.src
3333

3434
# copy the source tree
35-
rmtree_if_exists(root)
35+
preprocess.rmtree_if_exists(root)
3636
shutil.copytree(src, root)
3737

38-
rearrange_archive(root)
38+
preprocess.rearrange_archive(root)
3939

40-
rename_map = find_files_to_be_renamed(root)
41-
rename_files(rename_map)
40+
rename_map = preprocess.find_files_to_be_renamed(root)
41+
preprocess.rename_files(rename_map)
4242

4343
# clean the html files
44-
for fn in find_html_files(root):
45-
preprocess_html_file(root, fn, rename_map)
44+
for fn in preprocess.find_html_files(root):
45+
preprocess.preprocess_html_file(root, fn, rename_map)
4646

4747
# append css modifications
4848
with open(os.path.join(root, 'common/site_modules.css'), "a") as out:
@@ -53,7 +53,7 @@ def main():
5353

5454
for fn in [ os.path.join(root, 'common/site_modules.css'),
5555
os.path.join(root, 'common/ext.css') ]:
56-
preprocess_css_file(fn)
56+
preprocess.preprocess_css_file(fn)
5757

5858
if __name__ == "__main__":
5959
main()

preprocess_qch.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# You should have received a copy of the GNU General Public License
1818
# along with this program. If not, see http://www.gnu.org/licenses/.
1919

20-
from commands.preprocess_cssless import *
20+
from commands import preprocess_cssless
2121
import argparse
2222
import concurrent.futures
2323
import os
@@ -41,7 +41,7 @@ def main():
4141
shutil.rmtree(dest_root)
4242

4343
paths_list = []
44-
for root, dirs, files in os.walk(source_root):
44+
for root, _, files in os.walk(source_root):
4545
for file in files:
4646
if file.endswith(".html"):
4747
src_path = os.path.join(root, file)
@@ -51,13 +51,11 @@ def main():
5151
paths_list.append(tuple)
5252

5353
with concurrent.futures.ProcessPoolExecutor() as executor:
54-
futures = [ (executor.submit(preprocess_html_merge_cssless,
55-
src_path, dst_path), i)
54+
futures = [ (executor.submit(preprocess_cssless.preprocess_html_merge_cssless, src_path, dst_path), i)
5655
for i, (src_path, dst_path) in enumerate(paths_list) ]
5756

5857
for future, i in futures:
59-
print('Processing file: {}/{}: {}'.format(i, len(paths_list),
60-
paths_list[i][1]))
58+
print('Processing file: {}/{}: {}'.format(i, len(paths_list), paths_list[i][1]))
6159
output = future.result()
6260
if verbose:
6361
print(output)

tests/test_devhelp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# along with this program. If not, see http://www.gnu.org/licenses/.
1717

1818
import os
19-
from index_transform.devhelp import *
19+
from index_transform.devhelp import * #pylint: disable=unused-wildcard-import
2020
import unittest
2121

2222
class TestTransformDevhelp(unittest.TestCase):

tests/test_devhelp_qch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from lxml import etree
1919
import os
2020
import unittest
21-
from index_transform.devhelp_qch import *
21+
from index_transform.devhelp_qch import * #pylint: disable=unused-wildcard-import
2222

2323
class TestConvertDevhelpToQch(unittest.TestCase):
2424
def test_convert_devhelp_to_qch(self):

tests/test_preprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# You should have received a copy of the GNU General Public License
1919
# along with this program. If not, see http://www.gnu.org/licenses/.
2020

21-
from commands.preprocess import *
21+
from commands.preprocess import * #pylint: disable=unused-wildcard-import
2222
import io
2323
import os
2424
import unittest

tests/test_preprocess_cssless.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import os
1919
import unittest
20-
from commands.preprocess_cssless import *
20+
from commands.preprocess_cssless import * #pylint: disable=unused-wildcard-import
2121

2222
class TestPreprocessHtmlMergeCss(unittest.TestCase):
2323
def test_preprocess_html_merge_cssless(self):

0 commit comments

Comments
 (0)