MCPcopy Create free account
hub / github.com/BoomingTech/Piccolo / ProcessConfigOverrides

Function ProcessConfigOverrides

engine/3rdparty/tinyobjloader/deps/cpplint.py:6048–6121  ·  view source on GitHub ↗

Loads the configuration files and processes the config overrides. Args: filename: The name of the file being processed by the linter. Returns: False if the current |filename| should not be processed further.

(filename)

Source from the content-addressed store, hash-verified

6046 CheckForNewlineAtEOF(filename, lines, error)
6047
6048def ProcessConfigOverrides(filename):
6049 """ Loads the configuration files and processes the config overrides.
6050
6051 Args:
6052 filename: The name of the file being processed by the linter.
6053
6054 Returns:
6055 False if the current |filename| should not be processed further.
6056 """
6057
6058 abs_filename = os.path.abspath(filename)
6059 cfg_filters = []
6060 keep_looking = True
6061 while keep_looking:
6062 abs_path, base_name = os.path.split(abs_filename)
6063 if not base_name:
6064 break # Reached the root directory.
6065
6066 cfg_file = os.path.join(abs_path, "CPPLINT.cfg")
6067 abs_filename = abs_path
6068 if not os.path.isfile(cfg_file):
6069 continue
6070
6071 try:
6072 with open(cfg_file) as file_handle:
6073 for line in file_handle:
6074 line, _, _ = line.partition('#') # Remove comments.
6075 if not line.strip():
6076 continue
6077
6078 name, _, val = line.partition('=')
6079 name = name.strip()
6080 val = val.strip()
6081 if name == 'set noparent':
6082 keep_looking = False
6083 elif name == 'filter':
6084 cfg_filters.append(val)
6085 elif name == 'exclude_files':
6086 # When matching exclude_files pattern, use the base_name of
6087 # the current file name or the directory name we are processing.
6088 # For example, if we are checking for lint errors in /foo/bar/baz.cc
6089 # and we found the .cfg file at /foo/CPPLINT.cfg, then the config
6090 # file's "exclude_files" filter is meant to be checked against "bar"
6091 # and not "baz" nor "bar/baz.cc".
6092 if base_name:
6093 pattern = re.compile(val)
6094 if pattern.match(base_name):
6095 sys.stderr.write('Ignoring "%s": file excluded by "%s". '
6096 'File path component "%s" matches '
6097 'pattern "%s"\n' %
6098 (filename, cfg_file, base_name, val))
6099 return False
6100 elif name == 'linelength':
6101 global _line_length
6102 try:
6103 _line_length = int(val)
6104 except ValueError:
6105 sys.stderr.write('Line length must be numeric.')

Callers 1

ProcessFileFunction · 0.85

Calls 5

_AddFiltersFunction · 0.85
splitMethod · 0.80
appendMethod · 0.45
matchMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected