parameters: (dir_name, licence, diff, fix)
return_statement: return errors
docstring: Check all files in a directory contain the correct licence.
docstring_summary: Check all files in a directory contain the correct licence.
docstring_tokens: Check all files in a directory contain the correct licence .
function: def CheckLicenceForDir(dir_name, licence, diff, fix):
    """Check all files in a directory contain the correct licence."""
    errors = 0
    # glob doesn't support { } so we iterate instead
    for match in ['*.h', '*.cpp']:
      for file_name in glob.glob(os.path.join(dir_name, match)):
        # skip the generated protobuf code
        if '.pb.' in file_name:
          continue
        errors += CheckLicenceForFile(file_name, licence, CPP, diff, fix)
  
    js_licence = TransformCppToJsLicence(licence)
    for file_name in glob.glob(os.path.join(dir_name, '*.js')):
      errors += CheckLicenceForFile(file_name, js_licence, JS, diff, fix)
  
    for file_name in glob.glob(os.path.join(dir_name, '*.proto')):
      errors += CheckLicenceForFile(file_name, licence, PROTOBUF, diff, fix)
  
    python_licence = TransformCppToPythonLicence(licence)
    for file_name in glob.glob(os.path.join(dir_name, '*.py')):
      # skip the generated protobuf code
      if file_name.endswith('__init__.py') or file_name.endswith('pb2.py'):
        continue
      errors += CheckLicenceForFile(file_name, python_licence, PYTHON, diff, fix)
  
    return errors
function_tokens: def CheckLicenceForDir ( dir_name , licence , diff , fix ) : errors = 0 # glob doesn't support { } so we iterate instead for match in [ '*.h' , '*.cpp' ] : for file_name in glob . glob ( os . path . join ( dir_name , match ) ) : # skip the generated protobuf code if '.pb.' in file_name : continue errors += CheckLicenceForFile ( file_name , licence , CPP , diff , fix ) js_licence = TransformCppToJsLicence ( licence ) for file_name in glob . glob ( os . path . join ( dir_name , '*.js' ) ) : errors += CheckLicenceForFile ( file_name , js_licence , JS , diff , fix ) for file_name in glob . glob ( os . path . join ( dir_name , '*.proto' ) ) : errors += CheckLicenceForFile ( file_name , licence , PROTOBUF , diff , fix ) python_licence = TransformCppToPythonLicence ( licence ) for file_name in glob . glob ( os . path . join ( dir_name , '*.py' ) ) : # skip the generated protobuf code if file_name . endswith ( '__init__.py' ) or file_name . endswith ( 'pb2.py' ) : continue errors += CheckLicenceForFile ( file_name , python_licence , PYTHON , diff , fix ) return errors