docs: def _calculate_hash(self, filename, **kwargs):
          """
          Calculates the hash of the file and the hash of the file + metadata
          (passed in ``kwargs``).
  
          Args:
              filename (str): Name of the file
              testnet (bool): testnet flag. Defaults to False
              **kwargs: Additional metadata to be encoded with the file. Only
                  the values are used to compute the hash. Values are
                  ordered using their keys, so that the computation of the
                  hash is consistent. As an example, given::
  
                      File('filename', title='piece title', artist='artist')
  
                  the values ``('artist', 'piece title')`` would be used in that
                  order for the computation of the hash.
  
          """
          with open(filename, 'rb') as f:
              file_hash = hashlib.md5(f.read()).hexdigest()
  
          if kwargs:
              data = str(
                  [urepr(kwargs[k]) for k in sorted(kwargs)] + [file_hash])
          else:
              data = file_hash
  
          address_piece_with_metadata = str(
              bin_to_b58check(bin_hash160(data.encode()),
                              magicbyte=self._magicbyte)
          )
          address_piece = str(bin_to_b58check(bin_hash160(file_hash.encode()),
                                              magicbyte=self._magicbyte))
          return address_piece, address_piece_with_metadata