From 5c9d1bc66bb21f5832da37355a8b4e28664fcf35 Mon Sep 17 00:00:00 2001 From: Martin Herndl Date: Wed, 1 Sep 2021 14:45:37 +0200 Subject: [PATCH 1/2] Output instance specific options Fixes #16 --- nina_xmpp/__init__.py | 13 ++++++++++--- nina_xmpp/__main__.py | 6 +++++- nina_xmpp/locale/de/LC_MESSAGES/nina_xmpp.po | 7 +++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/nina_xmpp/__init__.py b/nina_xmpp/__init__.py index fd48e64..fc7020a 100644 --- a/nina_xmpp/__init__.py +++ b/nina_xmpp/__init__.py @@ -28,8 +28,9 @@ class NinaXMPP: commands = ('register', 'unregister', 'feeds', 'list', 'help') - def __init__(self, config): + def __init__(self, config, setup_config): self.config = config + self.setup_config = setup_config self.logger = logging.getLogger(self.__class__.__name__) self.db = init_db(config['database']) @@ -272,13 +273,16 @@ def list(self, jid, arg): def help(self, jid, arg): 'Show available commands' + version = self.setup_config.get('metadata', 'version', fallback='') + return '\n'.join([ '{cmd}\n {doc}'.format( cmd=cmd, doc=_(getattr(self, cmd).__doc__) ) for cmd in self.commands ] + [ - _('This bot is operated by {}').format(self.config['owner_jid']) + '', + _('This bot is operated in version {} by {}').format(version, self.config['owner_jid']), ]) def feeds(self, jid, arg): @@ -295,4 +299,7 @@ def feeds(self, jid, arg): url=url, last_modified=last_modified, )) - return '\n'.join(feeds) + return '\n'.join(feeds + [ + '', + _('The feeds are checked for updates every {} seconds').format(self.config['check_interval']), + ]) diff --git a/nina_xmpp/__main__.py b/nina_xmpp/__main__.py index 94c080e..60bf84f 100644 --- a/nina_xmpp/__main__.py +++ b/nina_xmpp/__main__.py @@ -1,4 +1,5 @@ import asyncio +import configparser from . import NinaXMPP @@ -16,7 +17,10 @@ def main(): config = yaml.safe_load(args.config_file) args.config_file.close() - main = NinaXMPP(config) + setup_config = configparser.ConfigParser() + setup_config.read('setup.cfg') + + main = NinaXMPP(config, setup_config) asyncio.run(main.run()) diff --git a/nina_xmpp/locale/de/LC_MESSAGES/nina_xmpp.po b/nina_xmpp/locale/de/LC_MESSAGES/nina_xmpp.po index 29e62ff..eec0969 100644 --- a/nina_xmpp/locale/de/LC_MESSAGES/nina_xmpp.po +++ b/nina_xmpp/locale/de/LC_MESSAGES/nina_xmpp.po @@ -61,14 +61,17 @@ msgstr "Keine aktiven Registrierungen" #: nina_xmpp/__init__.py:290 #, python-brace-format -msgid "This bot is operated by {}" -msgstr "Dieser Bot wird betrieben von {}" +msgid "This bot is operated in version {} by {}" +msgstr "Dieser Bot wird in Version {} betrieben von {}" #: nina_xmpp/__init__.py:303 #, python-brace-format msgid "{url} (last updated: {last_modified})" msgstr "{url} (zuletzt aktualisiert: {last_modified})" +msgid "The feeds are checked for updates every {} seconds" +msgstr "Die Warnquellen werden alle {} Sekunden auf Updates geprüft" + #: nina_xmpp/__init__.py:190 msgid "Effective" msgstr "Gilt ab" From 7253a70c5c8986f3f8a2da0f2ac3aa0eafd0db9c Mon Sep 17 00:00:00 2001 From: Martin Herndl Date: Wed, 6 Oct 2021 09:40:41 +0200 Subject: [PATCH 2/2] fixup! Output instance specific options --- nina_xmpp/__init__.py | 8 ++------ nina_xmpp/__main__.py | 6 +----- nina_xmpp/locale/de/LC_MESSAGES/nina_xmpp.po | 4 ++-- nina_xmpp/locale/nina_xmpp.pot | 3 +++ 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/nina_xmpp/__init__.py b/nina_xmpp/__init__.py index fc7020a..e7f5db0 100644 --- a/nina_xmpp/__init__.py +++ b/nina_xmpp/__init__.py @@ -28,9 +28,8 @@ class NinaXMPP: commands = ('register', 'unregister', 'feeds', 'list', 'help') - def __init__(self, config, setup_config): + def __init__(self, config): self.config = config - self.setup_config = setup_config self.logger = logging.getLogger(self.__class__.__name__) self.db = init_db(config['database']) @@ -273,16 +272,13 @@ def list(self, jid, arg): def help(self, jid, arg): 'Show available commands' - version = self.setup_config.get('metadata', 'version', fallback='') - return '\n'.join([ '{cmd}\n {doc}'.format( cmd=cmd, doc=_(getattr(self, cmd).__doc__) ) for cmd in self.commands ] + [ - '', - _('This bot is operated in version {} by {}').format(version, self.config['owner_jid']), + _('This bot is operated by {}').format(self.config['owner_jid']) ]) def feeds(self, jid, arg): diff --git a/nina_xmpp/__main__.py b/nina_xmpp/__main__.py index 60bf84f..94c080e 100644 --- a/nina_xmpp/__main__.py +++ b/nina_xmpp/__main__.py @@ -1,5 +1,4 @@ import asyncio -import configparser from . import NinaXMPP @@ -17,10 +16,7 @@ def main(): config = yaml.safe_load(args.config_file) args.config_file.close() - setup_config = configparser.ConfigParser() - setup_config.read('setup.cfg') - - main = NinaXMPP(config, setup_config) + main = NinaXMPP(config) asyncio.run(main.run()) diff --git a/nina_xmpp/locale/de/LC_MESSAGES/nina_xmpp.po b/nina_xmpp/locale/de/LC_MESSAGES/nina_xmpp.po index eec0969..a28ab22 100644 --- a/nina_xmpp/locale/de/LC_MESSAGES/nina_xmpp.po +++ b/nina_xmpp/locale/de/LC_MESSAGES/nina_xmpp.po @@ -61,8 +61,8 @@ msgstr "Keine aktiven Registrierungen" #: nina_xmpp/__init__.py:290 #, python-brace-format -msgid "This bot is operated in version {} by {}" -msgstr "Dieser Bot wird in Version {} betrieben von {}" +msgid "This bot is operated by {}" +msgstr "Dieser Bot wird betrieben von {}" #: nina_xmpp/__init__.py:303 #, python-brace-format diff --git a/nina_xmpp/locale/nina_xmpp.pot b/nina_xmpp/locale/nina_xmpp.pot index e082964..c0bb7bd 100644 --- a/nina_xmpp/locale/nina_xmpp.pot +++ b/nina_xmpp/locale/nina_xmpp.pot @@ -66,6 +66,9 @@ msgstr "" msgid "{url} (last updated: {last_modified})" msgstr "" +msgid "The feeds are checked for updates every {} seconds" +msgstr "" + #: nina_xmpp/__init__.py:190 msgid "Effective" msgstr ""