code: def get_file_sha1(filename_or_io):
      '''
      Calculates the SHA1 of a file or file object using a buffer to handle larger files.
      '''
  
      file_data = get_file_io(filename_or_io)
      cache_key = file_data.cache_key
  
      if cache_key and cache_key in FILE_SHAS:
          return FILE_SHAS[cache_key]
  
      with file_data as file_io:
          hasher = sha1()
          buff = file_io.read(BLOCKSIZE)
  
          while len(buff) > 0:
              if isinstance(buff, six.text_type):
                  buff = buff.encode('utf-8')
  
              hasher.update(buff)
              buff = file_io.read(BLOCKSIZE)
  
      digest = hasher.hexdigest()
  
      if cache_key:
          FILE_SHAS[cache_key] = digest
  
      return digesf get_file_sha1(filename_or_io):
      '''
      Calculates the SHA1 of a file or file object using a buffer to handle larger files.
      '''
  
      file_data = get_file_io(filename_or_io)
      cache_key = file_data.cache_key
  
      if cache_key and cache_key in FILE_SHAS:
          return FILE_SHAS[cache_key]
  
      with file_data as file_io:
          hasher = sha1()
          buff = file_io.read(BLOCKSIZE)
  
          while len(buff) > 0:
              if isinstance(buff, six.text_type):
                  buff = buff.encode('utf-8')
  
              hasher.update(buff)
              buff = file_io.read(BLOCKSIZE)
  
      digest = hasher.hexdigest()
  
      if cache_key:
          FILE_SHAS[cache_key] = digest
  
      return digest
docs: Calculates the SHA1 of a file or file object using a buffer to handle larger files.