From 98112d3987b5ce690c27d211c2a50630e3a5db88 Mon Sep 17 00:00:00 2001 From: Rahiel Kasim Date: Mon, 14 Mar 2016 14:50:12 +0100 Subject: [PATCH] move Updater and friends to ext submodule --- telegram/__init__.py | 21 ++++++++------------- telegram/ext/__init__.py | 28 ++++++++++++++++++++++++++++ telegram/{ => ext}/dispatcher.py | 2 +- telegram/{ => ext}/jobqueue.py | 0 telegram/{ => ext}/updatequeue.py | 0 telegram/{ => ext}/updater.py | 4 ++-- tests/test_jobqueue.py | 2 +- tests/test_updater.py | 2 +- 8 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 telegram/ext/__init__.py rename telegram/{ => ext}/dispatcher.py (99%) rename telegram/{ => ext}/jobqueue.py (100%) rename telegram/{ => ext}/updatequeue.py (100%) rename telegram/{ => ext}/updater.py (99%) diff --git a/telegram/__init__.py b/telegram/__init__.py index e28ac408a..8080b17de 100644 --- a/telegram/__init__.py +++ b/telegram/__init__.py @@ -49,26 +49,21 @@ from .inlinequeryresult import InlineQueryResultArticle, InlineQueryResultGif,\ InlineQueryResultMpeg4Gif, InlineQueryResultPhoto, InlineQueryResultVideo from .update import Update from .bot import Bot -from .dispatcher import Dispatcher -from .jobqueue import JobQueue -from .updatequeue import UpdateQueue def Updater(*args, **kwargs): """Load the updater module on invocation and return an Updater instance.""" - from .updater import Updater as Up + from .ext.updater import Updater as Up return Up(*args, **kwargs) __author__ = 'devs@python-telegram-bot.org' __version__ = '3.3' -__all__ = ('Bot', 'Updater', 'Dispatcher', 'Emoji', 'TelegramError', - 'InputFile', 'ReplyMarkup', 'ForceReply', 'ReplyKeyboardHide', - 'ReplyKeyboardMarkup', 'UserProfilePhotos', 'ChatAction', - 'Location', 'Contact', 'Video', 'Sticker', 'Document', 'File', - 'Audio', 'PhotoSize', 'Chat', 'Update', 'ParseMode', 'Message', - 'User', 'TelegramObject', 'NullHandler', 'Voice', 'JobQueue', - 'InlineQuery', 'ChosenInlineResult', 'InlineQueryResultArticle', +__all__ = ('Audio', 'Bot', 'Emoji', 'TelegramError', 'InputFile', 'ReplyMarkup', + 'Contact', 'ForceReply', 'ReplyKeyboardHide', 'ReplyKeyboardMarkup', + 'UserProfilePhotos', 'ChatAction', 'Location', 'Video', 'Document', + 'Sticker', 'File', 'PhotoSize', 'Update', 'ParseMode', 'Message', + 'User', 'TelegramObject', 'NullHandler', 'Voice', 'InlineQuery', + 'Chat', 'ChosenInlineResult', 'InlineQueryResultArticle', 'InlineQueryResultGif', 'InlineQueryResultPhoto', - 'InlineQueryResultMpeg4Gif', 'InlineQueryResultVideo', - 'UpdateQueue') + 'InlineQueryResultMpeg4Gif', 'InlineQueryResultVideo') diff --git a/telegram/ext/__init__.py b/telegram/ext/__init__.py new file mode 100644 index 000000000..5861c0ab4 --- /dev/null +++ b/telegram/ext/__init__.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# +# A library that provides a Python interface to the Telegram Bot API +# Copyright (C) 2015-2016 +# Leandro Toledo de Souza +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program 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 Lesser Public License for more details. +# +# You should have received a copy of the GNU Lesser Public License +# along with this program. If not, see [http://www.gnu.org/licenses/]. + +"""Extensions over the Telegram Bot API to facilitate bot making""" + +from .dispatcher import Dispatcher +from .jobqueue import JobQueue +from .updatequeue import UpdateQueue +from .updater import Updater + + +__all__ = ('Dispatcher', 'JobQueue', 'UpdateQueue', 'Updater') diff --git a/telegram/dispatcher.py b/telegram/ext/dispatcher.py similarity index 99% rename from telegram/dispatcher.py rename to telegram/ext/dispatcher.py index 3b63500fb..a5be8c82d 100644 --- a/telegram/dispatcher.py +++ b/telegram/ext/dispatcher.py @@ -27,7 +27,7 @@ from re import match from time import sleep from telegram import (TelegramError, Update, NullHandler) -from telegram.updatequeue import Empty +from telegram.ext.updatequeue import Empty H = NullHandler() logging.getLogger(__name__).addHandler(H) diff --git a/telegram/jobqueue.py b/telegram/ext/jobqueue.py similarity index 100% rename from telegram/jobqueue.py rename to telegram/ext/jobqueue.py diff --git a/telegram/updatequeue.py b/telegram/ext/updatequeue.py similarity index 100% rename from telegram/updatequeue.py rename to telegram/ext/updatequeue.py diff --git a/telegram/updater.py b/telegram/ext/updater.py similarity index 99% rename from telegram/updater.py rename to telegram/ext/updater.py index 68344f841..4a073ec4a 100644 --- a/telegram/updater.py +++ b/telegram/ext/updater.py @@ -28,8 +28,8 @@ from threading import Thread, Lock, current_thread, Event from time import sleep import subprocess from signal import signal, SIGINT, SIGTERM, SIGABRT -from telegram import (Bot, TelegramError, dispatcher, Dispatcher, - NullHandler, JobQueue, UpdateQueue) +from telegram import Bot, TelegramError, NullHandler +from telegram.ext import dispatcher, Dispatcher, JobQueue, UpdateQueue from telegram.utils.webhookhandler import (WebhookServer, WebhookHandler) H = NullHandler() diff --git a/tests/test_jobqueue.py b/tests/test_jobqueue.py index f90637ce4..84bcc9573 100644 --- a/tests/test_jobqueue.py +++ b/tests/test_jobqueue.py @@ -37,7 +37,7 @@ except ImportError: sys.path.append('.') -from telegram import JobQueue, Updater +from telegram.ext import JobQueue, Updater from tests.base import BaseTest # Enable logging diff --git a/tests/test_updater.py b/tests/test_updater.py index 46778dea1..61022d67e 100644 --- a/tests/test_updater.py +++ b/tests/test_updater.py @@ -48,7 +48,7 @@ except ImportError: sys.path.append('.') from telegram import Update, Message, TelegramError, User, Chat, Updater, Bot -from telegram.dispatcher import run_async +from telegram.ext.dispatcher import run_async from tests.base import BaseTest from threading import Lock, Thread