mirror of git://gcc.gnu.org/git/gcc.git
check_GNU_style.py: Read stdin if file argument is '-'
2017-05-29 Tom de Vries <tom@codesourcery.com> * check_GNU_style_lib.py (check_GNU_style_file): Treat file argument as file handle. Add and handle file_encoding argument. * check_GNU_style.py (main): Handle '-' file argument. Call check_GNU_style_file with file handle as argument. From-SVN: r248555
This commit is contained in:
parent
76baf5ca9d
commit
75017bb975
|
|
@ -1,3 +1,10 @@
|
||||||
|
2017-05-29 Tom de Vries <tom@codesourcery.com>
|
||||||
|
|
||||||
|
* check_GNU_style_lib.py (check_GNU_style_file): Treat file argument as
|
||||||
|
file handle. Add and handle file_encoding argument.
|
||||||
|
* check_GNU_style.py (main): Handle '-' file argument. Call
|
||||||
|
check_GNU_style_file with file handle as argument.
|
||||||
|
|
||||||
2017-05-29 Tom de Vries <tom@codesourcery.com>
|
2017-05-29 Tom de Vries <tom@codesourcery.com>
|
||||||
|
|
||||||
* check_GNU_style_lib.py: Use import_pip3 to import pip3 packages.
|
* check_GNU_style_lib.py: Use import_pip3 to import pip3 packages.
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
# <http://www.gnu.org/licenses/>. */
|
# <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import sys
|
||||||
from check_GNU_style_lib import check_GNU_style_file
|
from check_GNU_style_lib import check_GNU_style_file
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
@ -30,6 +31,13 @@ def main():
|
||||||
help = 'Display format',
|
help = 'Display format',
|
||||||
choices = ['stdio', 'quickfix'])
|
choices = ['stdio', 'quickfix'])
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
check_GNU_style_file(args.file, args.format)
|
filename = args.file
|
||||||
|
format = args.format
|
||||||
|
|
||||||
|
if filename == '-':
|
||||||
|
check_GNU_style_file(sys.stdin, None, format)
|
||||||
|
else:
|
||||||
|
with open(filename, 'rb') as diff_file:
|
||||||
|
check_GNU_style_file(diff_file, 'utf-8', format)
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,7 @@ class LineLengthTest(unittest.TestCase):
|
||||||
self.assertEqual(r.console_error,
|
self.assertEqual(r.console_error,
|
||||||
self.check.limit * 'a' + error_string(' = 123;'))
|
self.check.limit * 'a' + error_string(' = 123;'))
|
||||||
|
|
||||||
def check_GNU_style_file(file, format):
|
def check_GNU_style_file(file, file_encoding, format):
|
||||||
checks = [LineLengthCheck(), SpacesCheck(), TrailingWhitespaceCheck(),
|
checks = [LineLengthCheck(), SpacesCheck(), TrailingWhitespaceCheck(),
|
||||||
SentenceSeparatorCheck(), SentenceEndOfCommentCheck(),
|
SentenceSeparatorCheck(), SentenceEndOfCommentCheck(),
|
||||||
SentenceDotEndCheck(), FunctionParenthesisCheck(),
|
SentenceDotEndCheck(), FunctionParenthesisCheck(),
|
||||||
|
|
@ -231,8 +231,7 @@ def check_GNU_style_file(file, format):
|
||||||
BracesOnSeparateLineCheck(), TrailinigOperatorCheck()]
|
BracesOnSeparateLineCheck(), TrailinigOperatorCheck()]
|
||||||
errors = []
|
errors = []
|
||||||
|
|
||||||
with open(file, 'rb') as diff_file:
|
patch = PatchSet(file, encoding=file_encoding)
|
||||||
patch = PatchSet(diff_file, encoding = 'utf-8')
|
|
||||||
|
|
||||||
for pfile in patch.added_files + patch.modified_files:
|
for pfile in patch.added_files + patch.modified_files:
|
||||||
t = pfile.target_file.lstrip('b/')
|
t = pfile.target_file.lstrip('b/')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue