From 1a62196216a4fa2fb7f7160f8c50786623384a20 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 16 Jul 2019 11:49:06 -0400 Subject: [PATCH] seperation --- sopel_modules/SpiceBot/Update.py | 42 +------------------------- sopel_modules/SpiceBot/Version.py | 47 ++++++++++++++++++++++++++++++ sopel_modules/SpiceBot/__init__.py | 10 ++++--- 3 files changed, 54 insertions(+), 45 deletions(-) create mode 100644 sopel_modules/SpiceBot/Version.py diff --git a/sopel_modules/SpiceBot/Update.py b/sopel_modules/SpiceBot/Update.py index a6c445c..058002a 100644 --- a/sopel_modules/SpiceBot/Update.py +++ b/sopel_modules/SpiceBot/Update.py @@ -4,50 +4,10 @@ from __future__ import unicode_literals, absolute_import, division, print_functi This is the SpiceBot Update system. """ -import sopel + from sopel.config.types import StaticSection, ValidatedAttribute -import requests - -from .Config import config as botconfig - class SpiceBot_Update_MainSection(StaticSection): gitrepo = ValidatedAttribute('gitrepo', default="https://github.com/SpiceBot/SpiceBot") gitbranch = ValidatedAttribute('gitbranch', default="master") - - -class BotUpdates(): - - def __init__(self): - self.sopel = { - "version_local": sopel.version_info, - "version_local_num": sopel.__version__, - "version_url": 'https://sopel.chat/latest.json', - "version_online": None, - "version_online_num": None, - } - self.spicebot = False - - self.check_sopel() - - def check_sopel(self): - info = requests.get(self.sopel["version_url"], verify=botconfig.core.verify_ssl).json() - if self.sopel["version_local"].releaselevel == 'final': - self.sopel["version_online_num"] = info['version'] - self.sopel["notes"] = info['release_notes'] - else: - self.sopel["version_online_num"] = info['unstable'] - self.sopel["notes"] = info.get('unstable_notes', '') - if self.sopel["notes"]: - self.sopel["notes"] = 'Full release notes at ' + self.sopel["notes"] - - self.sopel["version_online"] = sopel._version_info(self.sopel["version_online_num"]) - - def check_spicebot(self): - return - self.sopel = True - # get actual version number, and commit count, and assemble a version - - -version = BotUpdates() diff --git a/sopel_modules/SpiceBot/Version.py b/sopel_modules/SpiceBot/Version.py new file mode 100644 index 0000000..048db7c --- /dev/null +++ b/sopel_modules/SpiceBot/Version.py @@ -0,0 +1,47 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot Update system. +""" + +import sopel + +import requests + +from .Config import config as botconfig + + +class BotVersion(): + + def __init__(self): + self.sopel = { + "version_local": sopel.version_info, + "version_local_num": sopel.__version__, + "version_url": 'https://sopel.chat/latest.json', + "version_online": None, + "version_online_num": None, + } + self.spicebot = False + + self.check_sopel() + + def check_sopel(self): + info = requests.get(self.sopel["version_url"], verify=botconfig.core.verify_ssl).json() + if self.sopel["version_local"].releaselevel == 'final': + self.sopel["version_online_num"] = info['version'] + self.sopel["notes"] = info['release_notes'] + else: + self.sopel["version_online_num"] = info['unstable'] + self.sopel["notes"] = info.get('unstable_notes', '') + if self.sopel["notes"]: + self.sopel["notes"] = 'Full release notes at ' + self.sopel["notes"] + + self.sopel["version_online"] = sopel._version_info(self.sopel["version_online_num"]) + + def check_spicebot(self): + return + self.sopel = True + # get actual version number, and commit count, and assemble a version + + +version = BotVersion() diff --git a/sopel_modules/SpiceBot/__init__.py b/sopel_modules/SpiceBot/__init__.py index e0836fa..fa35c97 100644 --- a/sopel_modules/SpiceBot/__init__.py +++ b/sopel_modules/SpiceBot/__init__.py @@ -7,6 +7,11 @@ This module contains references only for other modules to utilize. """ # pylama:ignore=W0401,W0611 + +from .configure import * +from .setup import * +from .shutdown import * + from .Config import * from .Logs import * from .Database import * @@ -32,12 +37,9 @@ from .Reddit import * from .DictComs import * from .Read import * from .Translate import * +from .Version import * -from .configure import * -from .setup import * -from .shutdown import * - __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net' __version__ = '0.1.1'