parameters: (filename_cpp, filename_h)
return_statement: return files_belong_to_same_module, common_path
docstring: Check if these two filenames belong to the same module.
  
      The concept of a 'module' here is a as follows:
      foo.h, foo-inl.h, foo.cpp, foo_test.cpp and foo_unittest.cpp belong to the
      same 'module' if they are in the same directory.
      some/path/public/xyzzy and some/path/internal/xyzzy are also considered
      to belong to the same module here.
  
      If the filename_cpp contains a longer path than the filename_h, for example,
      '/absolute/path/to/base/sysinfo.cpp', and this file would include
      'base/sysinfo.h', this function also produces the prefix needed to open the
      header. This is used by the caller of this function to more robustly open the
      header file. We don't have access to the real include paths in this context,
      so we need this guesswork here.
  
      Known bugs: tools/base/bar.cpp and base/bar.h belong to the same module
      according to this implementation. Because of this, this function gives
      some false positives. This should be sufficiently rare in practice.
  
      Args:
        filename_cpp: is the path for the .cpp file
        filename_h: is the path for the header path
  
      Returns:
        Tuple with a bool and a string:
        bool: True if filename_cpp and filename_h belong to the same module.
        string: the additional prefix needed to open the header file.
docstring_summary: Check if these two filenames belong to the same module.
docstring_tokens: Check if these two filenames belong to the same module .
function: def files_belong_to_same_module(filename_cpp, filename_h):
      """Check if these two filenames belong to the same module.
  
      The concept of a 'module' here is a as follows:
      foo.h, foo-inl.h, foo.cpp, foo_test.cpp and foo_unittest.cpp belong to the
      same 'module' if they are in the same directory.
      some/path/public/xyzzy and some/path/internal/xyzzy are also considered
      to belong to the same module here.
  
      If the filename_cpp contains a longer path than the filename_h, for example,
      '/absolute/path/to/base/sysinfo.cpp', and this file would include
      'base/sysinfo.h', this function also produces the prefix needed to open the
      header. This is used by the caller of this function to more robustly open the
      header file. We don't have access to the real include paths in this context,
      so we need this guesswork here.
  
      Known bugs: tools/base/bar.cpp and base/bar.h belong to the same module
      according to this implementation. Because of this, this function gives
      some false positives. This should be sufficiently rare in practice.
  
      Args:
        filename_cpp: is the path for the .cpp file
        filename_h: is the path for the header path
  
      Returns:
        Tuple with a bool and a string:
        bool: True if filename_cpp and filename_h belong to the same module.
        string: the additional prefix needed to open the header file.
      """
  
      if not filename_cpp.endswith('.cpp'):
          return (False, '')
      filename_cpp = filename_cpp[:-len('.cpp')]
      if filename_cpp.endswith('_unittest'):
          filename_cpp = filename_cpp[:-len('_unittest')]
      elif filename_cpp.endswith('_test'):
          filename_cpp = filename_cpp[:-len('_test')]
      filename_cpp = filename_cpp.replace('/public/', '/')
      filename_cpp = filename_cpp.replace('/internal/', '/')
  
      if not filename_h.endswith('.h'):
          return (False, '')
      filename_h = filename_h[:-len('.h')]
      if filename_h.endswith('-inl'):
          filename_h = filename_h[:-len('-inl')]
      filename_h = filename_h.replace('/public/', '/')
      filename_h = filename_h.replace('/internal/', '/')
  
      files_belong_to_same_module = filename_cpp.endswith(filename_h)
      common_path = ''
      if files_belong_to_same_module:
          common_path = filename_cpp[:-len(filename_h)]
      return files_belong_to_same_module, common_path
function_tokens: def files_belong_to_same_module ( filename_cpp , filename_h ) : if not filename_cpp . endswith ( '.cpp' ) : return ( False , '' ) filename_cpp = filename_cpp [ : - len ( '.cpp' ) ] if filename_cpp . endswith ( '_unittest' ) : filename_cpp = filename_cpp [ : - len ( '_unittest' ) ] elif filename_cpp . endswith ( '_test' ) : filename_cpp = filename_cpp [ : - len ( '_test' ) ] filename_cpp = filename_cpp . replace ( '/public/' , '/' ) filename_cpp = filename_cpp . replace ( '/internal/' , '/' ) if not filename_h . endswith ( '.h' ) : return ( False , '' ) filename_h = filename_h [ : - len ( '.h' ) ] if filename_h . endswith ( '-inl' ) : filename_h = filename_h [ : - len ( '-inl' ) ] filename_h = filename_h . replace ( '/public/' , '/' ) filename_h = filename_h . replace ( '/internal/' , '/' ) files_belong_to_same_module = filename_cpp . endswith ( filename_h ) common_path = '' if files_belong_to_same_module : common_path = filename_cpp [ : - len ( filename_h ) ] return files_belong_to_same_module , common_path