def _AddFilesThatAreSmallEnough(self, paths, openfunc):
    """Calls self.AddFile on files that are small enough.

    By small enough, we mean that their size is within
    self.resource_limits['max_file_size'] for application files, and
    'max_blob_size' otherwise. Files that are too large are logged as errors,
    and dropped (not sure why this isn't handled by raising an exception...).

    Args:
      paths: List of paths, relative to the app's base path.
      openfunc: A function that takes a paths element, and returns a file-like
        object.
    """
    StatusUpdate('Scanning files on local disk.', self.error_fh)
    num_files = 0
    for path in paths:
      file_handle = openfunc(path)
      try:
        file_length = GetFileLength(file_handle)


        file_classification = FileClassification(
            self.config, path, self.error_fh)
        if file_classification.IsApplicationFile():
          max_size = self.resource_limits['max_file_size']
        else:
          max_size = self.resource_limits['max_blob_size']


        if file_length > max_size:
          extra_msg = (' Consider --enable_jar_splitting.'
                       if JavaSupported() and path.endswith('jar')
                       else '')
          logging.error('Ignoring file \'%s\': Too long '
                        '(max %d bytes, file is %d bytes).%s',
                        path, max_size, file_length, extra_msg)
        else:
          logging.info('Processing file \'%s\'', path)
          self.AddFile(path, file_handle)
      finally:
        file_handle.close()


      num_files += 1
      if num_files % 500 == 0:
        StatusUpdate('Scanned %d files.' % num_files, self.error_fh)
dataset/ETHPy150Open GoogleCloudPlatform/python-compat-runtime/appengine-compat/exported_appengine_sdk/google/appengine/tools/appcfg.py/AppVersionUpload._AddFilesThatAreSmallEnough/original