From 1a5f884a16629e4797d6f6c944ad4027571fc607 Mon Sep 17 00:00:00 2001 From: Nikolay Zinov Date: Sat, 17 May 2014 16:31:59 +0400 Subject: [PATCH] refactor handlers structure for #52 --- handlers/__init__.py | 85 +++++++ .../{admin_page_handler.py => admin_page.py} | 7 +- .../base_handlers/admin_request_handler.py | 20 -- handlers/base_handlers/generic_handler.py | 7 - .../base_handlers/service_request_handler.py | 13 - handlers/base_handlers/web_request_handler.py | 43 ---- .../__init__.py} | 5 +- .../admin.py} | 2 +- handlers/game_log_viewer.py | 3 +- .../__init__.py | 0 .../complain_word.py} | 3 +- .../editor.py} | 5 +- .../frequency.py} | 5 +- .../unknown_words.py} | 2 +- .../{ => global_dictionary}/word_lookup.py | 4 +- .../words.py} | 5 +- handlers/link_device.py | 6 +- .../{log_n_res_handlers.py => log_saving.py} | 3 +- .../{newsfeed_handlers.py => newsfeed.py} | 6 +- handlers/{pregame_handlers.py => pregame.py} | 3 +- handlers/service/__init__.py | 1 + handlers/{ => service}/remove_duplicates.py | 3 +- .../calculation.py} | 8 +- ...ion_statistics_handler.py => functions.py} | 4 +- ...tion_handler.py => game_len_prediction.py} | 3 +- .../{update_mathplotlib_plots.py => plots.py} | 3 +- .../{total_statistics_handler.py => total.py} | 6 +- .../{word_statistics_handler.py => word.py} | 3 +- .../{userdictionary.py => user_dictionary.py} | 3 +- ..._request_handlers.py => user_properies.py} | 26 +- ...eation_handler.py => web_game_creation.py} | 6 +- main.py | 222 +++++++++--------- tests/frequency_dictionary_handler_test.py | 4 +- 33 files changed, 247 insertions(+), 272 deletions(-) rename handlers/{admin_page_handler.py => admin_page.py} (58%) delete mode 100644 handlers/base_handlers/admin_request_handler.py delete mode 100644 handlers/base_handlers/generic_handler.py delete mode 100644 handlers/base_handlers/service_request_handler.py delete mode 100644 handlers/base_handlers/web_request_handler.py rename handlers/{dictionaries_packages_handlers.py => dictionary_packages/__init__.py} (95%) rename handlers/{dictionaries_packages_admin_handlers.py => dictionary_packages/admin.py} (98%) rename handlers/{base_handlers => global_dictionary}/__init__.py (100%) rename handlers/{complain_word_handlers.py => global_dictionary/complain_word.py} (95%) rename handlers/{global_dictionary_editor_handlers.py => global_dictionary/editor.py} (94%) rename handlers/{frequency_dictionary_handlers.py => global_dictionary/frequency.py} (91%) rename handlers/{unknown_word_handler.py => global_dictionary/unknown_words.py} (92%) rename handlers/{ => global_dictionary}/word_lookup.py (74%) rename handlers/{global_dictionary_word_handlers.py => global_dictionary/words.py} (95%) rename handlers/{log_n_res_handlers.py => log_saving.py} (97%) rename handlers/{newsfeed_handlers.py => newsfeed.py} (96%) rename handlers/{pregame_handlers.py => pregame.py} (99%) create mode 100644 handlers/service/__init__.py rename handlers/{ => service}/remove_duplicates.py (96%) rename handlers/{recalc_rating_handler.py => statistics/calculation.py} (98%) rename handlers/statistics/{function_statistics_handler.py => functions.py} (96%) rename handlers/statistics/{game_len_prediction_handler.py => game_len_prediction.py} (94%) rename handlers/statistics/{update_mathplotlib_plots.py => plots.py} (98%) rename handlers/statistics/{total_statistics_handler.py => total.py} (94%) rename handlers/statistics/{word_statistics_handler.py => word.py} (96%) rename handlers/{userdictionary.py => user_dictionary.py} (96%) rename handlers/{base_handlers/api_request_handlers.py => user_properies.py} (84%) rename handlers/{web_game_creation_handler.py => web_game_creation.py} (71%) diff --git a/handlers/__init__.py b/handlers/__init__.py index f4bb036..f64a547 100644 --- a/handlers/__init__.py +++ b/handlers/__init__.py @@ -1 +1,86 @@ +from google.appengine.api import users +import webapp2 +from environment import JINJA_ENVIRONMENT +from objects.user_devices import get_device_and_user, User + __author__ = 'nikolay' + + +class GenericHandler(webapp2.RequestHandler): + def __init__(self, *args, **kwargs): + super(GenericHandler, self).__init__(*args, **kwargs) + + +class WebRequestHandler(GenericHandler): + user_key = None + user = None + + def dispatch(self): + self.user = users.get_current_user() + if self.user is None: + if self.login_required: + self.redirect(users.create_login_url(self.request.url)) + return + else: + self.user_key = (User.query(User.user_id == self.user.user_id()).get(keys_only=True) or + User(user_id=self.user.user_id(), user_object=self.user).put()) + webapp2.RequestHandler.dispatch(self) + + def draw_page(self, template_name, **render_data): + template = JINJA_ENVIRONMENT.get_template('templates/{}.html'.format(template_name)) + render_data['user_link'] = (users.create_logout_url('/') if self.user + else users.create_login_url(self.request.url)) + if self.user: + render_data['user_email'] = users.get_current_user().email() + else: + render_data['user_email'] = None + render_data['is_admin'] = users.is_current_user_admin() + self.response.write(template.render(render_data)) + + def __init__(self, *args, **kwargs): + self.login_required = False + super(WebRequestHandler, self).__init__(*args, **kwargs) + + +class AdminRequestHandler(WebRequestHandler): + def dispatch(self): + if users.get_current_user() is None: + self.redirect(users.create_login_url()) + if not users.is_current_user_admin(): + self.redirect('/') + else: + WebRequestHandler.dispatch(self) + + def __init__(self, *args, **kwargs): + super(AdminRequestHandler, self).__init__(*args, **kwargs) + self.login_required = True + + +class APIRequestHandler(GenericHandler): + def __init__(self, *args, **kwargs): + super(APIRequestHandler, self).__init__(*args, **kwargs) + + +class AuthorizedAPIRequestHandler(APIRequestHandler): + def __init__(self, *args, **kwargs): + super(APIRequestHandler, self).__init__(*args, **kwargs) + self.device_id = None + self.device_key = None + self.user_key = None + + def dispatch(self): + self.device_id = (self.request.route_kwargs.get('device_id', None) or + self.request.headers.get('TheHat-Device-Identity', None)) + if self.device_id is None: + self.response.headers.add("WWW-Authenticate", "device-id") + self.abort(401) + self.device_key, self.user_key = get_device_and_user(self.device_id) + super(APIRequestHandler, self).dispatch() + + +class ServiceRequestHandler(GenericHandler): + def __init__(self, *args, **kwargs): + super(ServiceRequestHandler, self).__init__(*args, **kwargs) + + def dispatch(self): + super(ServiceRequestHandler, self).dispatch() \ No newline at end of file diff --git a/handlers/admin_page_handler.py b/handlers/admin_page.py similarity index 58% rename from handlers/admin_page_handler.py rename to handlers/admin_page.py index ee1fd38..cce428c 100644 --- a/handlers/admin_page_handler.py +++ b/handlers/admin_page.py @@ -1,9 +1,6 @@ -__author__ = 'ivan' -from google.appengine.api import users -import webapp2 +from handlers import AdminRequestHandler -from environment import JINJA_ENVIRONMENT -from base_handlers.admin_request_handler import AdminRequestHandler +__author__ = 'ivan' class AdminPage(AdminRequestHandler): diff --git a/handlers/base_handlers/admin_request_handler.py b/handlers/base_handlers/admin_request_handler.py deleted file mode 100644 index 4975405..0000000 --- a/handlers/base_handlers/admin_request_handler.py +++ /dev/null @@ -1,20 +0,0 @@ -__author__ = 'ivan' - -from google.appengine.api import users - -from web_request_handler import WebRequestHandler - - -class AdminRequestHandler(WebRequestHandler): - - def dispatch(self): - if users.get_current_user() is None: - self.redirect(users.create_login_url()) - if not users.is_current_user_admin(): - self.redirect('/') - else: - WebRequestHandler.dispatch(self) - - def __init__(self, *args, **kwargs): - super(AdminRequestHandler, self).__init__(*args, **kwargs) - self.login_required = True \ No newline at end of file diff --git a/handlers/base_handlers/generic_handler.py b/handlers/base_handlers/generic_handler.py deleted file mode 100644 index 0679f3d..0000000 --- a/handlers/base_handlers/generic_handler.py +++ /dev/null @@ -1,7 +0,0 @@ -__author__ = 'ivan' -import webapp2 - - -class GenericHandler(webapp2.RequestHandler): - def __init__(self, *args, **kwargs): - super(GenericHandler, self).__init__(*args, **kwargs) diff --git a/handlers/base_handlers/service_request_handler.py b/handlers/base_handlers/service_request_handler.py deleted file mode 100644 index b1aaede..0000000 --- a/handlers/base_handlers/service_request_handler.py +++ /dev/null @@ -1,13 +0,0 @@ -__author__ = 'ivan' - -from generic_handler import GenericHandler -from google.appengine.api import users - - -class ServiceRequestHandler(GenericHandler): - def __init__(self, *args, **kwargs): - super(ServiceRequestHandler, self).__init__(*args, **kwargs) - - def dispatch(self): - super(ServiceRequestHandler, self).dispatch() - diff --git a/handlers/base_handlers/web_request_handler.py b/handlers/base_handlers/web_request_handler.py deleted file mode 100644 index 9b1201d..0000000 --- a/handlers/base_handlers/web_request_handler.py +++ /dev/null @@ -1,43 +0,0 @@ -__author__ = 'ivan' - -from google.appengine.api import users - -from generic_handler import GenericHandler -from objects.user_devices import User - -import webapp2 -from environment import JINJA_ENVIRONMENT - - -class WebRequestHandler(GenericHandler): - user_key = None - user = None - - def dispatch(self): - self.user = users.get_current_user() - if self.user is None: - if self.login_required: - self.redirect(users.create_login_url(self.request.url)) - return - else: - self.user_key = (User.query(User.user_id == self.user.user_id()).get(keys_only=True) or - User(user_id=self.user.user_id(), user_object=self.user).put()) - webapp2.RequestHandler.dispatch(self) - - def draw_page(self, template_name, **render_data): - template = JINJA_ENVIRONMENT.get_template('templates/{}.html'.format(template_name)) - render_data['user_link'] = (users.create_logout_url('/') if self.user - else users.create_login_url(self.request.url)) - if self.user: - render_data['user_email'] = users.get_current_user().email() - else: - render_data['user_email'] = None - render_data['is_admin'] = users.is_current_user_admin() - self.response.write(template.render(render_data)) - - - - def __init__(self, *args, **kwargs): - self.login_required = False - super(WebRequestHandler, self).__init__(*args, **kwargs) - diff --git a/handlers/dictionaries_packages_handlers.py b/handlers/dictionary_packages/__init__.py similarity index 95% rename from handlers/dictionaries_packages_handlers.py rename to handlers/dictionary_packages/__init__.py index d98a2d1..5b7d2e7 100644 --- a/handlers/dictionaries_packages_handlers.py +++ b/handlers/dictionary_packages/__init__.py @@ -1,8 +1,9 @@ +__author__ = 'nikolay' import json -from objects.user_devices import get_device_and_user + +from handlers import APIRequestHandler, AuthorizedAPIRequestHandler from objects.user_streams import UserStreams from objects.dictionaries_packages import PackagesStream, PackageDictionary -from base_handlers.api_request_handlers import APIRequestHandler, AuthorizedAPIRequestHandler class GetStreamsListHandler(APIRequestHandler): diff --git a/handlers/dictionaries_packages_admin_handlers.py b/handlers/dictionary_packages/admin.py similarity index 98% rename from handlers/dictionaries_packages_admin_handlers.py rename to handlers/dictionary_packages/admin.py index 409aa0a..2f78177 100644 --- a/handlers/dictionaries_packages_admin_handlers.py +++ b/handlers/dictionary_packages/admin.py @@ -1,8 +1,8 @@ from google.appengine.api import users +from handlers import AdminRequestHandler from objects.dictionaries_packages import PackagesStream, PackageDictionary from environment import * -from base_handlers.admin_request_handler import AdminRequestHandler def get_streams(): diff --git a/handlers/game_log_viewer.py b/handlers/game_log_viewer.py index 9485aef..a3dc837 100644 --- a/handlers/game_log_viewer.py +++ b/handlers/game_log_viewer.py @@ -1,5 +1,6 @@ +from handlers import AdminRequestHandler + __author__ = 'nikolay' -from handlers.base_handlers.admin_request_handler import AdminRequestHandler from google.appengine.ext import ndb import json diff --git a/handlers/base_handlers/__init__.py b/handlers/global_dictionary/__init__.py similarity index 100% rename from handlers/base_handlers/__init__.py rename to handlers/global_dictionary/__init__.py diff --git a/handlers/complain_word_handlers.py b/handlers/global_dictionary/complain_word.py similarity index 95% rename from handlers/complain_word_handlers.py rename to handlers/global_dictionary/complain_word.py index a31f098..1f0ef7a 100644 --- a/handlers/complain_word_handlers.py +++ b/handlers/global_dictionary/complain_word.py @@ -4,10 +4,9 @@ from google.appengine.ext import ndb +from handlers import AdminRequestHandler, AuthorizedAPIRequestHandler from objects.global_dictionary_word import GlobalDictionaryWord from objects.complained_word import ComplainedWord -from handlers.base_handlers.admin_request_handler import AdminRequestHandler -from handlers.base_handlers.api_request_handlers import AuthorizedAPIRequestHandler from objects.user_devices import get_device_and_user diff --git a/handlers/global_dictionary_editor_handlers.py b/handlers/global_dictionary/editor.py similarity index 94% rename from handlers/global_dictionary_editor_handlers.py rename to handlers/global_dictionary/editor.py index 725a6e3..ab17da7 100644 --- a/handlers/global_dictionary_editor_handlers.py +++ b/handlers/global_dictionary/editor.py @@ -1,11 +1,12 @@ +#TODO: this file is obsolete and must be rewritten +from handlers import AdminRequestHandler + __author__ = 'ivan' import json -import time from environment import JINJA_ENVIRONMENT from objects.global_dictionary_word import GlobalDictionaryWord -from handlers.base_handlers.admin_request_handler import AdminRequestHandler from objects.GlobalDictionaryJSON import GlobalDictionaryJson diff --git a/handlers/frequency_dictionary_handlers.py b/handlers/global_dictionary/frequency.py similarity index 91% rename from handlers/frequency_dictionary_handlers.py rename to handlers/global_dictionary/frequency.py index ce207a4..e7e0469 100644 --- a/handlers/frequency_dictionary_handlers.py +++ b/handlers/global_dictionary/frequency.py @@ -1,13 +1,12 @@ + __author__ = 'ivan' import json +from handlers import AdminRequestHandler, ServiceRequestHandler from google.appengine.api import taskqueue from google.appengine.ext import ndb -from handlers.base_handlers.admin_request_handler import AdminRequestHandler -from handlers.base_handlers.service_request_handler import ServiceRequestHandler - class WordFrequency(ndb.Model): word = ndb.StringProperty() diff --git a/handlers/unknown_word_handler.py b/handlers/global_dictionary/unknown_words.py similarity index 92% rename from handlers/unknown_word_handler.py rename to handlers/global_dictionary/unknown_words.py index 6a21b51..0e7f214 100644 --- a/handlers/unknown_word_handler.py +++ b/handlers/global_dictionary/unknown_words.py @@ -1,5 +1,5 @@ from google.appengine.ext import ndb -from handlers.base_handlers.admin_request_handler import AdminRequestHandler +from handlers import AdminRequestHandler from objects.global_dictionary_word import GlobalDictionaryWord __author__ = 'ivan' diff --git a/handlers/word_lookup.py b/handlers/global_dictionary/word_lookup.py similarity index 74% rename from handlers/word_lookup.py rename to handlers/global_dictionary/word_lookup.py index 781e0bf..3b15176 100644 --- a/handlers/word_lookup.py +++ b/handlers/global_dictionary/word_lookup.py @@ -1,8 +1,8 @@ +from handlers import AdminRequestHandler + __author__ = 'nikolay' from objects.global_dictionary_word import WordLookup -from handlers.base_handlers.admin_request_handler import AdminRequestHandler import json -from google.appengine.ext import ndb class AddLookups(AdminRequestHandler): diff --git a/handlers/global_dictionary_word_handlers.py b/handlers/global_dictionary/words.py similarity index 95% rename from handlers/global_dictionary_word_handlers.py rename to handlers/global_dictionary/words.py index 07eab6f..906fc34 100644 --- a/handlers/global_dictionary_word_handlers.py +++ b/handlers/global_dictionary/words.py @@ -1,3 +1,5 @@ +from handlers import AdminRequestHandler, APIRequestHandler, ServiceRequestHandler + __author__ = 'ivan' import time @@ -8,9 +10,6 @@ from objects.global_dictionary_word import GlobalDictionaryWord from objects.GlobalDictionaryJSON import GlobalDictionaryJson -from handlers.base_handlers.api_request_handlers import APIRequestHandler -from handlers.base_handlers.admin_request_handler import AdminRequestHandler -from handlers.base_handlers.service_request_handler import ServiceRequestHandler StrategyTypeChooseConstant = 200 diff --git a/handlers/link_device.py b/handlers/link_device.py index c5ab0de..97e6505 100644 --- a/handlers/link_device.py +++ b/handlers/link_device.py @@ -1,13 +1,13 @@ +from handlers import AuthorizedAPIRequestHandler, ServiceRequestHandler + __author__ = 'denspb' from google.appengine.api import users from google.appengine.api import taskqueue from google.appengine.ext import ndb -from handlers.base_handlers.api_request_handlers import AuthorizedAPIRequestHandler -from handlers.base_handlers.service_request_handler import ServiceRequestHandler from objects.user_devices import get_user -from handlers.userdictionary import merge_user_dictionary_data +from handlers.user_dictionary import merge_user_dictionary_data class LinkDevice(AuthorizedAPIRequestHandler): diff --git a/handlers/log_n_res_handlers.py b/handlers/log_saving.py similarity index 97% rename from handlers/log_n_res_handlers.py rename to handlers/log_saving.py index a27c903..64ea88d 100644 --- a/handlers/log_n_res_handlers.py +++ b/handlers/log_saving.py @@ -1,3 +1,5 @@ +from handlers import APIRequestHandler, AuthorizedAPIRequestHandler + __author__ = 'konstantin' import json import time @@ -8,7 +10,6 @@ from objects.user_devices import get_device_and_user from objects.pin_number import PinNumber from objects.game_results_log import GameLog, Results, SavedGame -from base_handlers.api_request_handlers import APIRequestHandler, AuthorizedAPIRequestHandler def make_timestamp(): diff --git a/handlers/newsfeed_handlers.py b/handlers/newsfeed.py similarity index 96% rename from handlers/newsfeed_handlers.py rename to handlers/newsfeed.py index fe6cd33..9bb1ed3 100644 --- a/handlers/newsfeed_handlers.py +++ b/handlers/newsfeed.py @@ -3,16 +3,12 @@ # v 0.2 -import os import time -import webapp2 from google.appengine.ext import db from webapp2_extras import json -from base_handlers.admin_request_handler import AdminRequestHandler -from base_handlers.api_request_handlers import APIRequestHandler - +from handlers import AdminRequestHandler, APIRequestHandler from environment import * diff --git a/handlers/pregame_handlers.py b/handlers/pregame.py similarity index 99% rename from handlers/pregame_handlers.py rename to handlers/pregame.py index d884d8e..ac0e55b 100644 --- a/handlers/pregame_handlers.py +++ b/handlers/pregame.py @@ -1,3 +1,5 @@ +from handlers import AuthorizedAPIRequestHandler + __author__ = 'nikolay' import random @@ -6,7 +8,6 @@ from google.appengine.ext import ndb from objects.pregame import PreGame, CurrentGame -from base_handlers.api_request_handlers import AuthorizedAPIRequestHandler class PreGameCreateHandler(AuthorizedAPIRequestHandler): diff --git a/handlers/service/__init__.py b/handlers/service/__init__.py new file mode 100644 index 0000000..f4bb036 --- /dev/null +++ b/handlers/service/__init__.py @@ -0,0 +1 @@ +__author__ = 'nikolay' diff --git a/handlers/remove_duplicates.py b/handlers/service/remove_duplicates.py similarity index 96% rename from handlers/remove_duplicates.py rename to handlers/service/remove_duplicates.py index 5f59e04..012567e 100644 --- a/handlers/remove_duplicates.py +++ b/handlers/service/remove_duplicates.py @@ -1,10 +1,11 @@ +from handlers import ServiceRequestHandler + __author__ = 'nikolay' import hashlib from google.appengine.ext import ndb from google.appengine.api import taskqueue -from handlers.base_handlers.service_request_handler import ServiceRequestHandler from objects.legacy_game_history import GameHistory diff --git a/handlers/recalc_rating_handler.py b/handlers/statistics/calculation.py similarity index 98% rename from handlers/recalc_rating_handler.py rename to handlers/statistics/calculation.py index 1db9040..842033e 100644 --- a/handlers/recalc_rating_handler.py +++ b/handlers/statistics/calculation.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +from handlers import AdminRequestHandler, ServiceRequestHandler + __author__ = 'nikolay' @@ -11,15 +13,13 @@ from google.appengine.api import taskqueue from google.appengine.api import memcache -from objects.global_dictionary_word import GlobalDictionaryWord, WordLookup +from objects.global_dictionary_word import GlobalDictionaryWord from environment import TRUESKILL_ENVIRONMENT from objects.game_results_log import GameLog from objects.legacy_game_history import GameHistory -from base_handlers.service_request_handler import ServiceRequestHandler -from base_handlers.admin_request_handler import AdminRequestHandler from objects.total_statistics_object import * from objects.unknown_word import UnknownWord -from handlers.statistics.game_len_prediction_handler import GameLength +from handlers.statistics.game_len_prediction import GameLength class BadGameError(Exception): diff --git a/handlers/statistics/function_statistics_handler.py b/handlers/statistics/functions.py similarity index 96% rename from handlers/statistics/function_statistics_handler.py rename to handlers/statistics/functions.py index b4b2eaf..a065053 100644 --- a/handlers/statistics/function_statistics_handler.py +++ b/handlers/statistics/functions.py @@ -1,8 +1,8 @@ +from handlers import AdminRequestHandler, ServiceRequestHandler + __author__ = 'ivan' from objects.global_dictionary_word import GlobalDictionaryWord -from handlers.base_handlers.service_request_handler import ServiceRequestHandler -from handlers.base_handlers.admin_request_handler import AdminRequestHandler from google.appengine.api import taskqueue from google.appengine.ext import ndb diff --git a/handlers/statistics/game_len_prediction_handler.py b/handlers/statistics/game_len_prediction.py similarity index 94% rename from handlers/statistics/game_len_prediction_handler.py rename to handlers/statistics/game_len_prediction.py index 198076f..239e758 100644 --- a/handlers/statistics/game_len_prediction_handler.py +++ b/handlers/statistics/game_len_prediction.py @@ -1,7 +1,8 @@ +from handlers import AdminRequestHandler + __author__ = 'ivan' from google.appengine.ext import ndb -from handlers.base_handlers.admin_request_handler import AdminRequestHandler import math import datetime diff --git a/handlers/statistics/update_mathplotlib_plots.py b/handlers/statistics/plots.py similarity index 98% rename from handlers/statistics/update_mathplotlib_plots.py rename to handlers/statistics/plots.py index b5616b1..606f1f5 100644 --- a/handlers/statistics/update_mathplotlib_plots.py +++ b/handlers/statistics/plots.py @@ -1,3 +1,5 @@ +from handlers import ServiceRequestHandler + __author__ = 'ivan' import StringIO @@ -6,7 +8,6 @@ from google.appengine.ext import ndb from google.appengine.api import taskqueue -from handlers.base_handlers.service_request_handler import ServiceRequestHandler from objects.global_dictionary_word import GlobalDictionaryWord diff --git a/handlers/statistics/total_statistics_handler.py b/handlers/statistics/total.py similarity index 94% rename from handlers/statistics/total_statistics_handler.py rename to handlers/statistics/total.py index 8614d47..8885079 100644 --- a/handlers/statistics/total_statistics_handler.py +++ b/handlers/statistics/total.py @@ -1,11 +1,11 @@ +from handlers import APIRequestHandler, WebRequestHandler + __author__ = 'ivan' from google.appengine.api import memcache -from handlers.base_handlers.web_request_handler import WebRequestHandler -from handlers.statistics.update_mathplotlib_plots import Plot +from handlers.statistics.plots import Plot from objects.total_statistics_object import * -from handlers.base_handlers.api_request_handlers import APIRequestHandler from objects.global_dictionary_word import GlobalDictionaryWord diff --git a/handlers/statistics/word_statistics_handler.py b/handlers/statistics/word.py similarity index 96% rename from handlers/statistics/word_statistics_handler.py rename to handlers/statistics/word.py index 7ca24ba..211b794 100644 --- a/handlers/statistics/word_statistics_handler.py +++ b/handlers/statistics/word.py @@ -1,6 +1,7 @@ +from handlers import WebRequestHandler + __author__ = 'ivan' -from handlers.base_handlers.web_request_handler import WebRequestHandler from objects.global_dictionary_word import GlobalDictionaryWord from google.appengine.api import memcache from random import randint diff --git a/handlers/userdictionary.py b/handlers/user_dictionary.py similarity index 96% rename from handlers/userdictionary.py rename to handlers/user_dictionary.py index ec30871..4222d66 100644 --- a/handlers/userdictionary.py +++ b/handlers/user_dictionary.py @@ -1,8 +1,7 @@ import json +from handlers import AuthorizedAPIRequestHandler, WebRequestHandler from objects.user_dictionary_word import UserDictionaryWord -from base_handlers.api_request_handlers import AuthorizedAPIRequestHandler -from base_handlers.web_request_handler import WebRequestHandler class UserDictionaryHandler(AuthorizedAPIRequestHandler): diff --git a/handlers/base_handlers/api_request_handlers.py b/handlers/user_properies.py similarity index 84% rename from handlers/base_handlers/api_request_handlers.py rename to handlers/user_properies.py index b45b514..c67a326 100644 --- a/handlers/base_handlers/api_request_handlers.py +++ b/handlers/user_properies.py @@ -1,31 +1,7 @@ __author__ = 'ivan' import json - -from generic_handler import GenericHandler -from objects.user_devices import get_device_and_user import logging - - -class APIRequestHandler(GenericHandler): - def __init__(self, *args, **kwargs): - super(APIRequestHandler, self).__init__(*args, **kwargs) - - -class AuthorizedAPIRequestHandler(APIRequestHandler): - def __init__(self, *args, **kwargs): - super(APIRequestHandler, self).__init__(*args, **kwargs) - self.device_id = None - self.device_key = None - self.user_key = None - - def dispatch(self): - self.device_id = (self.request.route_kwargs.get('device_id', None) or - self.request.headers.get('TheHat-Device-Identity', None)) - if self.device_id is None: - self.response.headers.add("WWW-Authenticate", "device-id") - self.abort(401) - self.device_key, self.user_key = get_device_and_user(self.device_id) - super(APIRequestHandler, self).dispatch() +from handlers import AuthorizedAPIRequestHandler class GetAllValues: diff --git a/handlers/web_game_creation_handler.py b/handlers/web_game_creation.py similarity index 71% rename from handlers/web_game_creation_handler.py rename to handlers/web_game_creation.py index ec7bbd3..7b1a79b 100644 --- a/handlers/web_game_creation_handler.py +++ b/handlers/web_game_creation.py @@ -1,8 +1,6 @@ -__author__ = 'ivan' - +from handlers import WebRequestHandler -from environment import JINJA_ENVIRONMENT -from handlers.base_handlers.web_request_handler import WebRequestHandler +__author__ = 'ivan' class WebGameCreationHandler(WebRequestHandler): diff --git a/main.py b/main.py index eafe261..9ed7e50 100644 --- a/main.py +++ b/main.py @@ -16,31 +16,31 @@ # import webapp2 +from handlers import WebRequestHandler import handlers -import handlers.dictionaries_packages_handlers -import handlers.dictionaries_packages_admin_handlers -import handlers.userdictionary -import handlers.log_n_res_handlers -import handlers.complain_word_handlers -import handlers.newsfeed_handlers -import handlers.global_dictionary_word_handlers -import handlers.recalc_rating_handler -import handlers.web_game_creation_handler +import handlers.dictionary_packages +import handlers.dictionary_packages.admin +import handlers.user_dictionary +import handlers.log_saving +import handlers.global_dictionary.complain_word +import handlers.newsfeed +import handlers.global_dictionary.words +import handlers.statistics.calculation +import handlers.web_game_creation import handlers.link_device -import handlers.statistics.word_statistics_handler -import handlers.statistics.update_mathplotlib_plots -import handlers.remove_duplicates -import handlers.admin_page_handler -import handlers.pregame_handlers -import handlers.statistics.total_statistics_handler -import handlers.frequency_dictionary_handlers +import handlers.statistics.word +import handlers.statistics.plots +import handlers.service.remove_duplicates +import handlers.admin_page +import handlers.pregame +import handlers.statistics.total +import handlers.global_dictionary.frequency import handlers.game_log_viewer -import handlers.unknown_word_handler -import handlers.word_lookup -import handlers.statistics.function_statistics_handler -import handlers.base_handlers.api_request_handlers -import handlers.statistics.game_len_prediction_handler -from handlers.base_handlers.web_request_handler import WebRequestHandler +import handlers.global_dictionary.unknown_words +import handlers.global_dictionary.word_lookup +import handlers.statistics.functions +import handlers.user_properies +import handlers.statistics.game_len_prediction class MainPage(WebRequestHandler): @@ -52,7 +52,7 @@ def get(self): #prediction handlers webapp2.Route(r'/admin/statistics/prediction', - handler=handlers.statistics.game_len_prediction_handler.GameLenPredictionHandler, + handler=handlers.statistics.game_len_prediction.GameLenPredictionHandler, name='prediction'), @@ -65,157 +65,157 @@ def get(self): #function statistics handler webapp2.Route(r'/admin/statistics/functions/add', - handler=handlers.statistics.function_statistics_handler.AddFunctionHandler, + handler=handlers.statistics.functions.AddFunctionHandler, name='add function'), webapp2.Route(r'/admin/statistics/functions/update', - handler=handlers.statistics.function_statistics_handler.UpdateFunctionsStatisticsHandler, + handler=handlers.statistics.functions.UpdateFunctionsStatisticsHandler, name='update stat'), webapp2.Route(r'/cron/statistics/functions/update', - handler=handlers.statistics.function_statistics_handler.CronUpdateResHandlers, + handler=handlers.statistics.functions.CronUpdateResHandlers, name='update stat cron'), webapp2.Route(r'/internal/statistics/functions/update/task_queue', - handler=handlers.statistics.function_statistics_handler.UpdateFunctionsStatisticsHandlerTaskQueue, + handler=handlers.statistics.functions.UpdateFunctionsStatisticsHandlerTaskQueue, name='update stat'), webapp2.Route(r'/internal/statistics/functions/update/task_queue/push_results', - handler=handlers.statistics.function_statistics_handler.push_results_task_queue, + handler=handlers.statistics.functions.push_results_task_queue, name='push results'), webapp2.Route(r'/admin/statistics/functions/show', - handler=handlers.statistics.function_statistics_handler.ResultShowHandler, + handler=handlers.statistics.functions.ResultShowHandler, name='push results'), #User api request handlers #user webapp2.Route(r'/api/settings/user/get/all', - handler=handlers.base_handlers.api_request_handlers.GetAllValues.User, + handler=handlers.user_properies.GetAllValues.User, name='get all values'), webapp2.Route(r'/api/settings/user/update', - handler=handlers.base_handlers.api_request_handlers.UpdateValues.User, + handler=handlers.user_properies.UpdateValues.User, name='get all values'), webapp2.Route(r'/api/settings/user/delete', - handler=handlers.base_handlers.api_request_handlers.DeleteValues.User, + handler=handlers.user_properies.DeleteValues.User, name='delete values'), webapp2.Route(r'/api/settings/user/version', - handler=handlers.base_handlers.api_request_handlers.GetLastUserVersion, + handler=handlers.user_properies.GetLastUserVersion, name='get version'), #this device webapp2.Route(r'/api/settings/device/get/all', - handler=handlers.base_handlers.api_request_handlers.GetAllValues.Device, + handler=handlers.user_properies.GetAllValues.Device, name='get all values'), webapp2.Route(r'/api/settings/device/update', - handler=handlers.base_handlers.api_request_handlers.UpdateValues.Device, + handler=handlers.user_properies.UpdateValues.Device, name='get all values'), webapp2.Route(r'/api/settings/device/delete', - handler=handlers.base_handlers.api_request_handlers.DeleteValues.Device, + handler=handlers.user_properies.DeleteValues.Device, name='delete values'), webapp2.Route(r'/api/settings/device/version', - handler=handlers.base_handlers.api_request_handlers.GetLastDeviceVersion, + handler=handlers.user_properies.GetLastDeviceVersion, name='get version'), #devices webapp2.Route(r'/api/settings/user_devices/get/all', - handler=handlers.base_handlers.api_request_handlers.GetAllValues.Devices, + handler=handlers.user_properies.GetAllValues.Devices, name='get all values'), webapp2.Route(r'/api/settings/user_devices/update', - handler=handlers.base_handlers.api_request_handlers.UpdateValues.Devices, + handler=handlers.user_properies.UpdateValues.Devices, name='get all values'), webapp2.Route(r'/api/settings/user_devices/delete', - handler=handlers.base_handlers.api_request_handlers.DeleteValues.Devices, + handler=handlers.user_properies.DeleteValues.Devices, name='delete values'), webapp2.Route(r'/api/settings/user_devices/version', - handler=handlers.base_handlers.api_request_handlers.GetLastDevicesVersion, + handler=handlers.user_properies.GetLastDevicesVersion, name='get version'), #end api andlers #Unknown words handlers webapp2.Route(r'/admin/unknown_word/list', - handler=handlers.unknown_word_handler.GetWordPageHandler, + handler=handlers.global_dictionary.unknown_words.GetWordPageHandler, name='get unknown words list'), webapp2.Route(r'/admin/unknown_word/add', - handler=handlers.unknown_word_handler.AddWordHanler, + handler=handlers.global_dictionary.unknown_words.AddWordHanler, name='add word'), webapp2.Route(r'/admin/unknown_word/ignore', - handler=handlers.unknown_word_handler.IgnoreWordHanler, + handler=handlers.global_dictionary.unknown_words.IgnoreWordHanler, name='ignore word'), #Frequency dictionary handlers webapp2.Route(r'/admin/frequency_dictionary/add', - handler=handlers.frequency_dictionary_handlers.MakeDictionaryHandler, + handler=handlers.global_dictionary.frequency.MakeDictionaryHandler, name='add dict'), webapp2.Route(r'/admin/frequency_dictionary/delete', - handler=handlers.frequency_dictionary_handlers.DeleteDictionary, + handler=handlers.global_dictionary.frequency.DeleteDictionary, name='delete dict'), webapp2.Route(r'/internal/frequency_dictionary/delete/task_queue', - handler=handlers.frequency_dictionary_handlers.DeleteDictionaryTaskQueue, + handler=handlers.global_dictionary.frequency.DeleteDictionaryTaskQueue, name='delete dict'), webapp2.Route(r'/internal/frequency_dictionary/add/task_queue', - handler=handlers.frequency_dictionary_handlers.MakeDictionaryTaskQueueHandler, + handler=handlers.global_dictionary.frequency.MakeDictionaryTaskQueueHandler, name='add dict task_queue'), #Word lookup handlers webapp2.Route(r'/admin/word_lookup/add', - handler=handlers.word_lookup.AddLookups, + handler=handlers.global_dictionary.word_lookup.AddLookups, name="add_lookups"), #recalc rating & make_statistics handlers #web webapp2.Route(r'/admin/logs_processing', - handler=handlers.recalc_rating_handler.LogsAdminPage), + handler=handlers.statistics.calculation.LogsAdminPage), webapp2.Route(r'/cron/update_plots/start/', - handler=handlers.statistics.update_mathplotlib_plots.runUpdateAll), + handler=handlers.statistics.plots.runUpdateAll), #service webapp2.Route(r'/internal/update_heatmap/task_queue', - handler=handlers.statistics.update_mathplotlib_plots.UpdateHeatMapTaskQueue, + handler=handlers.statistics.plots.UpdateHeatMapTaskQueue, name='update heatmap task queue'), webapp2.Route(r'/internal/update_scatter/task_queue', - handler=handlers.statistics.update_mathplotlib_plots.UpdateScatterPlotTaskQueue, + handler=handlers.statistics.plots.UpdateScatterPlotTaskQueue, name='update heatmap task queue'), webapp2.Route(r'/internal/update_d/task_queue', - handler=handlers.statistics.update_mathplotlib_plots.UpdateDPlotHeatMapTaskQueue, + handler=handlers.statistics.plots.UpdateDPlotHeatMapTaskQueue, name='update d task queue'), webapp2.Route(r'/internal/add_game_to_statistic', - handler=handlers.recalc_rating_handler.AddGameHandler, + handler=handlers.statistics.calculation.AddGameHandler, name='add_game_Statistic'), webapp2.Route(r'/internal/recalc_all_logs', - handler=handlers.recalc_rating_handler.RecalcAllLogs), + handler=handlers.statistics.calculation.RecalcAllLogs), #User dictionary handlers - (r'/html/udict/edit', handlers.userdictionary.DrawWebpage), - (r'/html/udict/proc', handlers.userdictionary.ProcWebpage), + (r'/html/udict/edit', handlers.user_dictionary.DrawWebpage), + (r'/html/udict/proc', handlers.user_dictionary.ProcWebpage), webapp2.Route(r'//api/udict/', - handler=handlers.userdictionary.UserDictionaryHandler, + handler=handlers.user_dictionary.UserDictionaryHandler, name='udict_update'), webapp2.Route(r'//api/udict/since/', - handler=handlers.userdictionary.UserDictionaryHandler, + handler=handlers.user_dictionary.UserDictionaryHandler, name='udict_since'), webapp2.Route(r'//api/udict', - handler=handlers.userdictionary.UserDictionaryHandler, + handler=handlers.user_dictionary.UserDictionaryHandler, name='udict_get'), #Web handlers (r'/', MainPage), - (r'/admin', handlers.admin_page_handler.AdminPage), + (r'/admin', handlers.admin_page.AdminPage), webapp2.Route(r'/user/create_game', - handler=handlers.web_game_creation_handler.WebGameCreationHandler, + handler=handlers.web_game_creation.WebGameCreationHandler, name='create_game'), webapp2.Route(r'/remove_duplicates', - handler=handlers.remove_duplicates.RemoveDuplicates, + handler=handlers.service.remove_duplicates.RemoveDuplicates, name='remove_duplicates'), webapp2.Route(r'/images/scatter_plot/', - handler=handlers.statistics.total_statistics_handler.ScattedPlotHandler, + handler=handlers.statistics.total.ScattedPlotHandler, name='scatter_plot'), webapp2.Route(r'/images/heatmap_plot/', - handler=handlers.statistics.total_statistics_handler.HeatmapPlotHandler, + handler=handlers.statistics.total.HeatmapPlotHandler, name='heatmap_plot'), webapp2.Route(r'/images/d_plot', - handler=handlers.statistics.total_statistics_handler.DPlotHandler, + handler=handlers.statistics.total.DPlotHandler, name='d_plot'), #Statistics web handlers webapp2.Route(r'/statistics/word_statistics', - handler=handlers.statistics.word_statistics_handler.WordStatisticsHandler, + handler=handlers.statistics.word.WordStatisticsHandler, name='stats'), webapp2.Route('/statistics/total_statistics', - handler=handlers.statistics.total_statistics_handler.TotalStatisticsHandler, + handler=handlers.statistics.total.TotalStatisticsHandler, name="total statistics handler"), webapp2.Route('/admin/view_game_log', handler=handlers.game_log_viewer.GameLogViewer, @@ -226,147 +226,147 @@ def get(self): #gamelog handlers webapp2.Route(r'//game_log', - handler=handlers.log_n_res_handlers.GameLogHandler, + handler=handlers.log_saving.GameLogHandler, name='upload_log'), #migration route: to be removed webapp2.Route(r'//game_log/', - handler=handlers.log_n_res_handlers.GameLogHandler), + handler=handlers.log_saving.GameLogHandler), webapp2.Route(r'//game_results/', - handler=handlers.log_n_res_handlers.GameResultsHandler, + handler=handlers.log_saving.GameResultsHandler, name='upload_results'), webapp2.Route(r'//game_results/since/', - handler=handlers.log_n_res_handlers.GameResultsUpdateHandler, + handler=handlers.log_saving.GameResultsUpdateHandler, name='check_for_results'), webapp2.Route(r'//get_results/', - handler=handlers.log_n_res_handlers.GameResultsHandler, + handler=handlers.log_saving.GameResultsHandler, name='get_results'), webapp2.Route(r'/save_game', - handler=handlers.log_n_res_handlers.SaveGameHandler, + handler=handlers.log_saving.SaveGameHandler, name='save_game'), webapp2.Route(r'/save_game/', - handler=handlers.log_n_res_handlers.SaveGameHandler, + handler=handlers.log_saving.SaveGameHandler, name='load_game'), #Word streams handlers webapp2.Route(r'/admin/streams', - handler=handlers.dictionaries_packages_admin_handlers.AddStreamHandler, + handler=handlers.dictionary_packages.admin.AddStreamHandler, name='edit_words'), - webapp2.Route(r'//streams', handler=handlers.dictionaries_packages_handlers.GetStreamsListHandler, + webapp2.Route(r'//streams', handler=handlers.dictionary_packages.GetStreamsListHandler, name='stream_list'), webapp2.Route(r'//streams/' r'/to/', - handler=handlers.dictionaries_packages_handlers.ChangeStreamStateHandler, + handler=handlers.dictionary_packages.ChangeStreamStateHandler, name='change_stream_state'), webapp2.Route(r'//streams/', - handler=handlers.dictionaries_packages_handlers.GetPackagesListHandler, + handler=handlers.dictionary_packages.GetPackagesListHandler, name='package_list'), webapp2.Route(r'//streams/packages/', - handler=handlers.dictionaries_packages_handlers.GetPackageHandler, + handler=handlers.dictionary_packages.GetPackageHandler, name='get_package'), webapp2.Route(r'/admin/streams//packages/add', - handler=handlers.dictionaries_packages_admin_handlers.AddPackageHandler, + handler=handlers.dictionary_packages.admin.AddPackageHandler, name='add_package'), webapp2.Route(r'/admin/streams/packages//words', - handler=handlers.dictionaries_packages_admin_handlers.ChangeWordsHandler, + handler=handlers.dictionary_packages.admin.ChangeWordsHandler, name='change_words'), #Pregame handlers webapp2.Route(r'//pregame/create', - handler=handlers.pregame_handlers.PreGameCreateHandler, + handler=handlers.pregame.PreGameCreateHandler, name='pregame_create'), webapp2.Route(r'//pregame/join', - handler=handlers.pregame_handlers.PreGameJoinHandler, + handler=handlers.pregame.PreGameJoinHandler, name='pregame_join'), webapp2.Route(r'//pregame/get_current_game', - handler=handlers.pregame_handlers.PreGameCurrentHandler, + handler=handlers.pregame.PreGameCurrentHandler, name='pregame_current'), webapp2.Route(r'//pregame/', - handler=handlers.pregame_handlers.PreGameHandler, + handler=handlers.pregame.PreGameHandler, name='pregame_get'), webapp2.Route(r'//pregame//update', - handler=handlers.pregame_handlers.PreGameUpdateHandler, + handler=handlers.pregame.PreGameUpdateHandler, name='pregame_update'), webapp2.Route(r'//pregame//version', - handler=handlers.pregame_handlers.PreGameVersionHandler, + handler=handlers.pregame.PreGameVersionHandler, name='pregame_version'), webapp2.Route(r'//pregame/' r'/since/', - handler=handlers.pregame_handlers.PreGameSinceHandler, + handler=handlers.pregame.PreGameSinceHandler, name='pregame_since'), webapp2.Route(r'//pregame//start', - handler=handlers.pregame_handlers.PreGameStartHandler, + handler=handlers.pregame.PreGameStartHandler, name='pregame_start'), webapp2.Route(r'//pregame//abort', - handler=handlers.pregame_handlers.PreGameAbortHandler, + handler=handlers.pregame.PreGameAbortHandler, name='pregame_abort'), #Newsfeed handlers webapp2.Route(r'/news/', - handler=handlers.newsfeed_handlers.ShowNewsHandler, + handler=handlers.newsfeed.ShowNewsHandler, name="show news"), webapp2.Route(r'/news/login', - handler=handlers.newsfeed_handlers.LoginPageHandler, + handler=handlers.newsfeed.LoginPageHandler, name='login to news'), webapp2.Route(r'/news/add', - handler=handlers.newsfeed_handlers.AddNewsHandler, + handler=handlers.newsfeed.AddNewsHandler, name='add news'), webapp2.Route(r'/news/list', - handler=handlers.newsfeed_handlers.ListOfNewsHandler, + handler=handlers.newsfeed.ListOfNewsHandler, name="list of news"), webapp2.Route(r'/news/load/(\d+)', - handler=handlers.newsfeed_handlers.LoadNewsHandler, + handler=handlers.newsfeed.LoadNewsHandler, name="show news"), #Complain words handlers #admin handlers webapp2.Route('/admin/complain/list', - handler=handlers.complain_word_handlers.ShowComplainedWords, + handler=handlers.global_dictionary.complain_word.ShowComplainedWords, name='show_complained_words'), webapp2.Route('/admin/complain/clear', - handler=handlers.complain_word_handlers.DeleteComplainedWords, + handler=handlers.global_dictionary.complain_word.DeleteComplainedWords, name='delete_complained_words'), webapp2.Route('/admin/complain/cancel', - handler=handlers.complain_word_handlers.DeleteComplainedWord, + handler=handlers.global_dictionary.complain_word.DeleteComplainedWord, name='delete_current_complained_word'), webapp2.Route('/admin/complain/postpone', - handler=handlers.complain_word_handlers.PostponeComplainedWord, + handler=handlers.global_dictionary.complain_word.PostponeComplainedWord, name='postpone'), webapp2.Route('/admin/complain/remove', - handler=handlers.complain_word_handlers.DeleteFromGlobalDictionaryHandler, + handler=handlers.global_dictionary.complain_word.DeleteFromGlobalDictionaryHandler, name='delete_from_global'), #Authorized api requests webapp2.Route(r'//complain', - handler=handlers.complain_word_handlers.ComplainWordHandler, + handler=handlers.global_dictionary.complain_word.ComplainWordHandler, name='complain_word'), #GlobalDictionary handlers #admin handlers webapp2.Route(r'/admin/global_dictionary/add_words', - handler=handlers.global_dictionary_word_handlers.WordsAddHandler, + handler=handlers.global_dictionary.words.WordsAddHandler, name='add words to global'), webapp2.Route(r'/admin/global_dictionary/delete', - handler=handlers.global_dictionary_word_handlers.DeleteDictionary, + handler=handlers.global_dictionary.words.DeleteDictionary, name='delete'), webapp2.Route(r'/internal/global_dictionary/delete/task_queue', - handler=handlers.global_dictionary_word_handlers.DeleteDictionaryTaskQueue, + handler=handlers.global_dictionary.words.DeleteDictionaryTaskQueue, name='delete task_queue'), webapp2.Route(r'/admin/global_dictionary/update_json', - handler=handlers.global_dictionary_word_handlers.UpdateJsonHandler, + handler=handlers.global_dictionary.words.UpdateJsonHandler, name='update json'), webapp2.Route(r'/admin/global_dictionary/update_json/all', - handler=handlers.global_dictionary_word_handlers.UpdateAllJsonsHandler, + handler=handlers.global_dictionary.words.UpdateAllJsonsHandler, name="update all jsons"), #api handlers webapp2.Route(r'/api/global_dictionary/get_words/', - handler=handlers.global_dictionary_word_handlers.GlobalDictionaryGetWordsHandler, + handler=handlers.global_dictionary.words.GlobalDictionaryGetWordsHandler, name='get words'), #service handlers webapp2.Route(r'/internal/global_dictionary/add_words/task_queue', - handler=handlers.global_dictionary_word_handlers.TaskQueueAddWords, + handler=handlers.global_dictionary.words.TaskQueueAddWords, name='add words to global task queue'), webapp2.Route(r'/internal/global_dictionary/update_json/task_queue', - handler=handlers.global_dictionary_word_handlers.TaskQueueUpdateJson, + handler=handlers.global_dictionary.words.TaskQueueUpdateJson, name='update json task queue') diff --git a/tests/frequency_dictionary_handler_test.py b/tests/frequency_dictionary_handler_test.py index 431c4c5..dc9757a 100644 --- a/tests/frequency_dictionary_handler_test.py +++ b/tests/frequency_dictionary_handler_test.py @@ -1,12 +1,12 @@ __author__ = 'ivan' -import unittest2 import json import base64 +import unittest2 from google.appengine.ext import testbed -from handlers.frequency_dictionary_handlers import WordFrequency +from global_dictionary.frequency import WordFrequency from tests.base_functions import * import main