Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim-plugins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwurstsalat <mailtrash@posteo.de>2022-11-29 21:34:20 +0300
committerwurstsalat <mailtrash@posteo.de>2022-11-29 21:34:20 +0300
commitff9cedf90a455649c0ba4f5c0271c58e9e23d2bf (patch)
treebc3660b89224f26b6535920ffcbd37069411a6aa
parente97f055f69e29365c8c20d7705561580267595fe (diff)
[plugins_translations] Type annotations, linting
-rw-r--r--plugins_translations/__init__.py2
-rw-r--r--plugins_translations/plugins_translations.py30
2 files changed, 25 insertions, 7 deletions
diff --git a/plugins_translations/__init__.py b/plugins_translations/__init__.py
index ac2604e..214ea73 100644
--- a/plugins_translations/__init__.py
+++ b/plugins_translations/__init__.py
@@ -1 +1 @@
-from .plugins_translations import PluginsTranslationsPlugin
+from .plugins_translations import PluginsTranslationsPlugin # type: ignore
diff --git a/plugins_translations/plugins_translations.py b/plugins_translations/plugins_translations.py
index a8e0c14..684cb50 100644
--- a/plugins_translations/plugins_translations.py
+++ b/plugins_translations/plugins_translations.py
@@ -1,3 +1,21 @@
+# This file is part of Gajim.
+#
+# Gajim is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published
+# by the Free Software Foundation; version 3 only.
+#
+# Gajim is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
+
+from __future__ import annotations
+
+from typing import cast
+
import logging
import os
import shutil
@@ -13,17 +31,17 @@ log = logging.getLogger('gajim.p.plugins_translations')
class PluginsTranslationsPlugin(GajimPlugin):
- def init(self):
+ def init(self) -> None:
self.description = _('This plugin contains translations for other '
'Gajim plugins. Please restart Gajim after '
'enabling this plugin.')
self.config_dialog = None
- self.config_default_values = {'last_version': '0'}
+ self.config_default_values = {'last_version': ('0', '')}
self.locale_dir = Path(configpaths.get('PLUGINS_USER')) / 'locale'
- def activate(self):
+ def activate(self) -> None:
current_version = str(self.manifest.version)
- if self.config['last_version'] == current_version:
+ if cast(str, self.config['last_version']) == current_version:
return
files = glob(self.__path__ + '/*.mo')
@@ -43,11 +61,11 @@ class PluginsTranslationsPlugin(GajimPlugin):
self.config['last_version'] = current_version
- def _remove_translations(self):
+ def _remove_translations(self) -> None:
log.info('Removing old translations...')
if self.locale_dir.exists():
shutil.rmtree(str(self.locale_dir))
- def deactivate(self):
+ def deactivate(self) -> None:
self._remove_translations()
self.config['last_version'] = '0'