[PATCH] D21974: [clang-include-fixer] fix PEP8 warnings
Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 4 09:54:27 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL274511: [clang-include-fixer] fix PEP8 warnings (authored by d0k).
Changed prior to commit:
http://reviews.llvm.org/D21974?vs=62680&id=62695#toc
Repository:
rL LLVM
http://reviews.llvm.org/D21974
Files:
clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
Index: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
===================================================================
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py
@@ -28,22 +28,23 @@
if vim.eval('exists("g:clang_include_fixer_path")') == "1":
binary = vim.eval('g:clang_include_fixer_path')
-maximum_suggested_headers=3
+maximum_suggested_headers = 3
if vim.eval('exists("g:clang_include_fixer_maximum_suggested_headers")') == "1":
maximum_suggested_headers = max(
1,
vim.eval('g:clang_include_fixer_maximum_suggested_headers'))
-increment_num=5
+increment_num = 5
if vim.eval('exists("g:clang_include_fixer_increment_num")') == "1":
increment_num = max(
1,
vim.eval('g:clang_include_fixer_increment_num'))
+
def GetUserSelection(message, headers, maximum_suggested_headers):
eval_message = message + '\n'
for idx, header in enumerate(headers[0:maximum_suggested_headers]):
- eval_message += "({0}). {1}\n".format(idx+1, header)
+ eval_message += "({0}). {1}\n".format(idx + 1, header)
eval_message += "Enter (q) to quit;"
if maximum_suggested_headers < len(headers):
eval_message += " (m) to show {0} more candidates.".format(
@@ -69,7 +70,8 @@
# don't need to wait for another include-fixer run.
print >> sys.stderr, "Invalid option:", res
return GetUserSelection(message, headers, maximum_suggested_headers)
- return headers[idx-1]
+ return headers[idx - 1]
+
def execute(command, text):
p = subprocess.Popen(command,
@@ -79,7 +81,7 @@
def InsertHeaderToVimBuffer(header, text):
- command = [binary, "-stdin", "-insert-header="+json.dumps(header),
+ command = [binary, "-stdin", "-insert-header=" + json.dumps(header),
vim.current.buffer.name]
stdout, stderr = execute(command, text)
if stdout:
@@ -104,8 +106,8 @@
text = '\n'.join(buf)
# Run command to get all headers.
- command = [binary, "-stdin", "-output-headers", "-db="+args.db,
- "-input="+args.input, vim.current.buffer.name]
+ command = [binary, "-stdin", "-output-headers", "-db=" + args.db,
+ "-input=" + args.input, vim.current.buffer.name]
stdout, stderr = execute(command, text)
if stderr:
print >> sys.stderr, "Error while running clang-include-fixer: " + stderr
@@ -127,16 +129,16 @@
# If there is only one suggested header, insert it directly.
if len(headers) == 1 or maximum_suggested_headers == 1:
InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
- "Headers":[headers[0]]}, text)
+ "Headers": [headers[0]]}, text)
print "Added #include {0} for {1}.\n".format(headers[0], symbol)
return
try:
selected = GetUserSelection("choose a header file for {0}.".format(symbol),
headers, maximum_suggested_headers)
# Insert a selected header.
InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
- "Headers":[selected]}, text)
+ "Headers": [selected]}, text)
print "Added #include {0} for {1}.\n".format(selected, symbol)
except Exception as error:
print >> sys.stderr, error.message
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21974.62695.patch
Type: text/x-patch
Size: 3338 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160704/eba1ba71/attachment.bin>
More information about the cfe-commits
mailing list