Summary: Silence few PEP8 warnings.
Reviewers: hokein
Reviewed By: hokein
Subscribers: Eugene.Zelenko, xazax.hun, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D78985
#!/usr/bin/env python
#
-#===- add_new_check.py - clang-tidy check generator ----------*- python -*--===#
+#===- add_new_check.py - clang-tidy check generator ---------*- python -*--===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
-#===------------------------------------------------------------------------===#
+#===-----------------------------------------------------------------------===#
from __future__ import print_function
import re
import sys
-# Adapts the module's CMakelist file. Returns 'True' if it could add a new entry
-# and 'False' if the entry already existed.
+
+# Adapts the module's CMakelist file. Returns 'True' if it could add a new
+# entry and 'False' if the entry already existed.
def adapt_cmake(module_path, check_name_camel):
filename = os.path.join(module_path, 'CMakeLists.txt')
with open(filename, 'r') as f:
with open(filename, 'w') as f:
note_added = False
header_found = False
- next_header_found = False
add_note_here = False
for line in lines:
add_note_here = True
if match_next:
- next_header_found = True
add_note_here = True
if match:
#!/usr/bin/env python
#
-#===- rename_check.py - clang-tidy check renamer -------------*- python -*--===#
+#===- rename_check.py - clang-tidy check renamer ------------*- python -*--===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
-#===------------------------------------------------------------------------===#
+#===-----------------------------------------------------------------------===#
import argparse
import glob
with open(fileName, "w") as f:
f.write(txt)
+
def replaceInFile(fileName, sFrom, sTo):
if sFrom == sTo:
return
os.rename(fileName, newFileName)
return newFileName
+
def deleteMatchingLines(fileName, pattern):
lines = None
with open(fileName, "r") as f:
return True
+
def getListOfFiles(clang_tidy_path):
files = glob.glob(os.path.join(clang_tidy_path, '*'))
for dirname in files:
'clang-tidy', 'checks', '*'))
return [filename for filename in files if os.path.isfile(filename)]
-# Adapts the module's CMakelist file. Returns 'True' if it could add a new entry
-# and 'False' if the entry already existed.
+
+# Adapts the module's CMakelist file. Returns 'True' if it could add a new
+# entry and 'False' if the entry already existed.
def adapt_cmake(module_path, check_name_camel):
filename = os.path.join(module_path, 'CMakeLists.txt')
with open(filename, 'r') as f:
with open(filename, 'wb') as f:
note_added = False
header_found = False
- next_header_found = False
add_note_here = False
for line in lines:
add_note_here = True
if match_next:
- next_header_found = True
add_note_here = True
if match:
+ ' --update-docs')
add_release_notes(clang_tidy_path, args.old_check_name, args.new_check_name)
+
if __name__ == '__main__':
main()
#!/usr/bin/env python
#
-#===- clang-tidy-diff.py - ClangTidy Diff Checker ------------*- python -*--===#
+#===- clang-tidy-diff.py - ClangTidy Diff Checker -----------*- python -*--===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
-#===------------------------------------------------------------------------===#
+#===-----------------------------------------------------------------------===#
r"""
ClangTidy Diff Checker
sys.stderr.write('Failed: ' + str(e) + ': '.join(command) + '\n')
finally:
with lock:
- if (not timeout is None) and (not watchdog is None):
+ if not (timeout is None or watchdog is None):
if not watchdog.is_alive():
sys.stderr.write('Terminated by timeout: ' +
' '.join(command) + '\n')
t.daemon = True
t.start()
+
def merge_replacement_files(tmpdir, mergefile):
"""Merge all replacement files in a directory into a single file"""
# The fixes suggested by clang-tidy >= 4.0.0 are given under
# include/clang/Tooling/ReplacementsYaml.h, but the value
# is actually never used inside clang-apply-replacements,
# so we set it to '' here.
- output = { 'MainSourceFile': '', mergekey: merged }
+ output = {'MainSourceFile': '', mergekey: merged}
with open(mergefile, 'w') as out:
yaml.safe_dump(output, out)
else:
#!/usr/bin/env python
#
-#===- run-clang-tidy.py - Parallel clang-tidy runner ---------*- python -*--===#
+#===- run-clang-tidy.py - Parallel clang-tidy runner --------*- python -*--===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
-#===------------------------------------------------------------------------===#
+#===-----------------------------------------------------------------------===#
# FIXME: Integrate with clang-tidy-diff.py
+
"""
Parallel clang-tidy runner
==========================
else:
import queue as queue
+
def find_compilation_database(path):
"""Adjusts the directory until a compilation database is found."""
result = './'
"""Merge all replacement files in a directory into a single file"""
# The fixes suggested by clang-tidy >= 4.0.0 are given under
# the top level key 'Diagnostics' in the output yaml files
- mergekey="Diagnostics"
+ mergekey = "Diagnostics"
merged=[]
for replacefile in glob.iglob(os.path.join(tmpdir, '*.yaml')):
content = yaml.safe_load(open(replacefile, 'r'))
# include/clang/Tooling/ReplacementsYaml.h, but the value
# is actually never used inside clang-apply-replacements,
# so we set it to '' here.
- output = { 'MainSourceFile': '', mergekey: merged }
+ output = {'MainSourceFile': '', mergekey: merged}
with open(mergefile, 'w') as out:
yaml.safe_dump(output, out)
else:
except:
print('Error applying fixes.\n', file=sys.stderr)
traceback.print_exc()
- return_code=1
+ return_code = 1
if tmpdir:
shutil.rmtree(tmpdir)
sys.exit(return_code)
+
if __name__ == '__main__':
main()