MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / ProcessFile

Function ProcessFile

rtpose_wrapper/scripts/cpp_lint.py:4689–4754  ·  view source on GitHub ↗

Does google-lint on a single file. Args: filename: The name of the file to parse. vlevel: The level of errors to report. Every error of confidence >= verbose_level will be reported. 0 is a good default. extra_check_functions: An array of additional check functions that will be

(filename, vlevel, extra_check_functions=[])

Source from the content-addressed store, hash-verified

4687 CheckForNewlineAtEOF(filename, lines, error)
4688
4689def ProcessFile(filename, vlevel, extra_check_functions=[]):
4690 """Does google-lint on a single file.
4691
4692 Args:
4693 filename: The name of the file to parse.
4694
4695 vlevel: The level of errors to report. Every error of confidence
4696 >= verbose_level will be reported. 0 is a good default.
4697
4698 extra_check_functions: An array of additional check functions that will be
4699 run on each source line. Each function takes 4
4700 arguments: filename, clean_lines, line, error
4701 """
4702
4703 _SetVerboseLevel(vlevel)
4704
4705 try:
4706 # Support the UNIX convention of using "-" for stdin. Note that
4707 # we are not opening the file with universal newline support
4708 # (which codecs doesn't support anyway), so the resulting lines do
4709 # contain trailing '\r' characters if we are reading a file that
4710 # has CRLF endings.
4711 # If after the split a trailing '\r' is present, it is removed
4712 # below. If it is not expected to be present (i.e. os.linesep !=
4713 # '\r\n' as in Windows), a warning is issued below if this file
4714 # is processed.
4715
4716 if filename == '-':
4717 lines = codecs.StreamReaderWriter(sys.stdin,
4718 codecs.getreader('utf8'),
4719 codecs.getwriter('utf8'),
4720 'replace').read().split('\n')
4721 else:
4722 lines = codecs.open(filename, 'r', 'utf8', 'replace').read().split('\n')
4723
4724 carriage_return_found = False
4725 # Remove trailing '\r'.
4726 for linenum in range(len(lines)):
4727 if lines[linenum].endswith('\r'):
4728 lines[linenum] = lines[linenum].rstrip('\r')
4729 carriage_return_found = True
4730
4731 except IOError:
4732 sys.stderr.write(
4733 "Skipping input '%s': Can't open for reading\n" % filename)
4734 return
4735
4736 # Note, if no dot is found, this will give the entire filename as the ext.
4737 file_extension = filename[filename.rfind('.') + 1:]
4738
4739 # When reading from stdin, the extension is unknown, so no cpplint tests
4740 # should rely on the extension.
4741 if filename != '-' and file_extension not in _valid_extensions:
4742 sys.stderr.write('Ignoring %s; not a valid file name '
4743 '(%s)\n' % (filename, ', '.join(_valid_extensions)))
4744 else:
4745 ProcessFileData(filename, file_extension, lines, Error,
4746 extra_check_functions)

Callers 1

mainFunction · 0.85

Calls 6

_SetVerboseLevelFunction · 0.85
ProcessFileDataFunction · 0.85
ErrorFunction · 0.85
splitMethod · 0.80
openMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected