<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_keywords(layer, keywords):
 """Write keywords for a datasource. This is a wrapper method that will 'do the right thing' to store keywords for the given datasource. In particular, if the datasource is remote (e.g. a database connection) it will write the keywords from the keywords store. :param layer: A QGIS QgsMapLayer instance. :type layer: qgis.core.QgsMapLayer :param keywords: A dict containing all the keywords to be written for the layer. :type keywords: dict :raises: UnsupportedProviderError """

        if not isinstance(layer, QgsMapLayer):
            raise Exception(
                tr('The layer is not a QgsMapLayer : {type}').format(
                    type=type(layer)))

        source = layer.source()
        write_iso19115_metadata(source, keywords)