MCPcopy Create free account
hub / github.com/tensorflow/tfjs / ProcessConfigOverrides

Function ProcessConfigOverrides

tfjs-backend-wasm/tools/cpplint.py:5946–6028  ·  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

5944 CheckForNewlineAtEOF(filename, lines, error)
5945
5946def ProcessConfigOverrides(filename):
5947 """ Loads the configuration files and processes the config overrides.
5948
5949 Args:
5950 filename: The name of the file being processed by the linter.
5951
5952 Returns:
5953 False if the current |filename| should not be processed further.
5954 """
5955
5956 abs_filename = os.path.abspath(filename)
5957 cfg_filters = []
5958 keep_looking = True
5959 while keep_looking:
5960 abs_path, base_name = os.path.split(abs_filename)
5961 if not base_name:
5962 break # Reached the root directory.
5963
5964 cfg_file = os.path.join(abs_path, "CPPLINT.cfg")
5965 abs_filename = abs_path
5966 if not os.path.isfile(cfg_file):
5967 continue
5968
5969 try:
5970 with open(cfg_file) as file_handle:
5971 for line in file_handle:
5972 line, _, _ = line.partition('#') # Remove comments.
5973 if not line.strip():
5974 continue
5975
5976 name, _, val = line.partition('=')
5977 name = name.strip()
5978 val = val.strip()
5979 if name == 'set noparent':
5980 keep_looking = False
5981 elif name == 'filter':
5982 cfg_filters.append(val)
5983 elif name == 'exclude_files':
5984 # When matching exclude_files pattern, use the base_name of
5985 # the current file name or the directory name we are processing.
5986 # For example, if we are checking for lint errors in /foo/bar/baz.cc
5987 # and we found the .cfg file at /foo/CPPLINT.cfg, then the config
5988 # file's "exclude_files" filter is meant to be checked against "bar"
5989 # and not "baz" nor "bar/baz.cc".
5990 if base_name:
5991 pattern = re.compile(val)
5992 if pattern.match(base_name):
5993 if _cpplint_state.quiet:
5994 # Suppress "Ignoring file" warning when using --quiet.
5995 return False
5996 sys.stderr.write('Ignoring "%s": file excluded by "%s". '
5997 'File path component "%s" matches '
5998 'pattern "%s"\n' %
5999 (filename, cfg_file, base_name, val))
6000 return False
6001 elif name == 'linelength':
6002 global _line_length
6003 try:

Callers 1

ProcessFileFunction · 0.85

Calls 8

ProcessHppHeadersOptionFunction · 0.85
_AddFiltersFunction · 0.85
joinMethod · 0.80
appendMethod · 0.80
splitMethod · 0.65
writeMethod · 0.65
intFunction · 0.50
compileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…