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

Function GetHeaderGuardCPPVariable

rtpose_wrapper/scripts/cpp_lint.py:1384–1405  ·  view source on GitHub ↗

Returns the CPP variable that should be used as a header guard. Args: filename: The name of a C++ header file. Returns: The CPP variable that should be used as a header guard in the named file.

(filename)

Source from the content-addressed store, hash-verified

1382
1383
1384def GetHeaderGuardCPPVariable(filename):
1385 """Returns the CPP variable that should be used as a header guard.
1386
1387 Args:
1388 filename: The name of a C++ header file.
1389
1390 Returns:
1391 The CPP variable that should be used as a header guard in the
1392 named file.
1393
1394 """
1395
1396 # Restores original filename in case that cpplint is invoked from Emacs's
1397 # flymake.
1398 filename = re.sub(r'_flymake\.h$', '.h', filename)
1399 filename = re.sub(r'/\.flymake/([^/]*)$', r'/\1', filename)
1400
1401 fileinfo = FileInfo(filename)
1402 file_path_from_root = fileinfo.RepositoryName()
1403 if _root:
1404 file_path_from_root = re.sub('^' + _root + os.sep, '', file_path_from_root)
1405 return re.sub(r'[-./\s]', '_', file_path_from_root).upper() + '_'
1406
1407
1408def CheckForHeaderGuard(filename, lines, error):

Callers 2

CheckForHeaderGuardFunction · 0.85
CheckStyleFunction · 0.85

Calls 2

RepositoryNameMethod · 0.95
FileInfoClass · 0.85

Tested by

no test coverage detected