After some research based on this question.
I found a solution to disable a plugin repository:
from qgis.PyQt.QtCore import QSettings
from pyplugin_installer import instance
from qgis.utils import updateAvailablePlugins
plugin_repository_name = 'Dépôt officiel des extensions QGIS'
settings = QSettings()
for setting in settings.allKeys():
if setting.find('{}/enabled'.format(plugin_repository_name)) > 0:
settings.setValue(setting, False)
updateAvailablePlugins()
instance().reloadAndExportData()
And enable it :
from qgis.PyQt.QtCore import QSettings
from pyplugin_installer import instance
from qgis.utils import updateAvailablePlugins
plugin_repository_name = 'Dépôt officiel des extensions QGIS'
settings = QSettings()
for setting in settings.allKeys():
if setting.find('{}/enabled'.format(plugin_repository_name)) > 0:
settings.setValue(setting, True)
updateAvailablePlugins()
instance().reloadAndExportData()