# Path: pushkin/database/database.py
# ENGINE = None
# SESSION = None
# ALEMBIC_CONFIG = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'alembic.ini')
#         ENGINE = create_engine(config.sqlalchemy_url, poolclass=pool.NullPool)
#         SESSION = sessionmaker(bind=ENGINE)
# def init_db():
# def create_database():
# def upgrade_database():
# def get_head_revision():
# def get_current_revision():
# def execute_query(query):
# def execute_query_with_results(query):
# def session_scope():
# def get_device_tokens(login_id):
# def get_raw_messages(login_id, title, content, screen, game, world_id, dry_run, message_id=0, event_ts_bigint=None,
#                      expiry_millis=None, priority=GCM2.PRIORITY_NORMAL, filter_platform_id=None, filter_device_token=None):
# def update_canonicals(canonicals):
# def update_unregistered_devices(unregistered):
# def process_user_login(login_id, language_id, platform_id, device_token, application_version):
# def upsert_login(login_id, language_id):
# def upsert_device(login_id, platform_id, device_token, application_version, unregistered_ts=None):
# def get_all_logins():
# def get_all_message_blacklist():
# def upsert_message_blacklist(login_id, blacklist):
# def get_login(login_id):
# def get_devices(login):
# def delete_login(login):
# def delete_device(device):
# def get_localized_message(login_id, message_id):
# def upsert_message(message_name, cooldown_ts, trigger_event_id, screen, expiry_millis, priority):
# def upsert_message_localization(message_name, language_id, message_title, message_text):
# def add_message(message_name, language_id, message_title, message_text, trigger_event_id=None, cooldown_ts=None,
#                 screen='', expiry_millis=None, priority=GCM2.PRIORITY_NORMAL):
# def get_all_messages():
# def get_message(message_name):
# def get_message_localizations(message):
# def delete_message(message):
# def delete_message_localization(message_localization):
# def get_event_to_message_mapping():
# def get_and_update_messages_to_send(user_message_set):
# 
# Path: pushkin/context.py
# PERSIST_LOGGER_PREFFIX = 'persist_'
# def setup_loggers():
# def setup_configuration(configuration_filename):
# def start_processors():
# 
# Path: pushkin/config.py
# DATABASE_CONFIG_SECTION = 'Database'
# SERVER_SPECIFIC_CONFIG_SECTION = 'ServerSpecific'
# EVENT_CONFIG_SECTION = 'Event'
# LOG_CONFIG_SECTION = 'Log'
# SERVER_CONFIG_SECTION = 'Server'
# MESSENGER_CONFIG_SECTION = 'Messenger'
# REQUEST_PROCESSOR_CONFIG_SECTION = 'RequestProcessor'
# SENDER_CONFIG_SECTION = 'Sender'
# REQUEST_HANDLER_SECTION = 'RequestHandler'
# def init(configuration_file):
# 
# Path: pushkin/util/tools.py
# def is_integer(value):
#     """
#     Checks if a value is of integer type
# 
#     :param value:
#     :return: True if value is integer, False otherwise
#     """
#     try:
#         int(value)
#         return True
#     except ValueError:
#         return False


from collections import defaultdict
from pushkin.database import database
from pushkin import context
from pushkin import config
from pushkin.util.tools import is_integer
import re
            return parameter

        def get_parameter_map(parametrized_text):
            parameter_names = [key.group(0).strip("{}") for key in
                               PARAM_REGEX.finditer(parametrized_text)]
            parameter_map = {
                param_name: get_parameter(param_name)
                for param_name in parameter_names
            }
            return parameter_map

        raw_messages = []
        if self.event_id == event.event_id:

            filter_platform_id = event_params.get('platform_id')
            if filter_platform_id is not None:
                filter_platform_id = int(filter_platform_id)
            filter_device_token = event_params.get('device_token')
            for message_id in self.message_ids:
                if message_id not in context.message_blacklist.get(event.user_id, set()):
                    try:
                        localized_message = database.get_localized_message(event.user_id, message_id)

                        if localized_message is not None:
                            text_parameter_map = get_parameter_map(localized_message.message_text)
                            title_parameter_map = get_parameter_map(localized_message.message_title)
                            raw_messages.extend(
                                database.get_raw_messages(
                                    login_id=event.user_id, title=localized_message.message_title.encode('utf-8').format(**title_parameter_map).decode('utf-8'),
                                    content=localized_message.message_text.encode('utf-8').format(**text_parameter_map).decode('utf-8'),

# Path: pushkin/database/database.py
# ENGINE = None
# SESSION = None
# ALEMBIC_CONFIG = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'alembic.ini')
#         ENGINE = create_engine(config.sqlalchemy_url, poolclass=pool.NullPool)
#         SESSION = sessionmaker(bind=ENGINE)
# def init_db():
# def create_database():
# def upgrade_database():
# def get_head_revision():
# def get_current_revision():
# def execute_query(query):
# def execute_query_with_results(query):
# def session_scope():
# def get_device_tokens(login_id):
# def get_raw_messages(login_id, title, content, screen, game, world_id, dry_run, message_id=0, event_ts_bigint=None,
#                      expiry_millis=None, priority=GCM2.PRIORITY_NORMAL, filter_platform_id=None, filter_device_token=None):
# def update_canonicals(canonicals):
# def update_unregistered_devices(unregistered):
# def process_user_login(login_id, language_id, platform_id, device_token, application_version):
# def upsert_login(login_id, language_id):
# def upsert_device(login_id, platform_id, device_token, application_version, unregistered_ts=None):
# def get_all_logins():
# def get_all_message_blacklist():
# def upsert_message_blacklist(login_id, blacklist):
# def get_login(login_id):
# def get_devices(login):
# def delete_login(login):
# def delete_device(device):
# def get_localized_message(login_id, message_id):
# def upsert_message(message_name, cooldown_ts, trigger_event_id, screen, expiry_millis, priority):
# def upsert_message_localization(message_name, language_id, message_title, message_text):
# def add_message(message_name, language_id, message_title, message_text, trigger_event_id=None, cooldown_ts=None,
#                 screen='', expiry_millis=None, priority=GCM2.PRIORITY_NORMAL):
# def get_all_messages():
# def get_message(message_name):
# def get_message_localizations(message):
# def delete_message(message):
# def delete_message_localization(message_localization):
# def get_event_to_message_mapping():
# def get_and_update_messages_to_send(user_message_set):
# 
# Path: pushkin/context.py
# PERSIST_LOGGER_PREFFIX = 'persist_'
# def setup_loggers():
# def setup_configuration(configuration_filename):
# def start_processors():
# 
# Path: pushkin/config.py
# DATABASE_CONFIG_SECTION = 'Database'
# SERVER_SPECIFIC_CONFIG_SECTION = 'ServerSpecific'
# EVENT_CONFIG_SECTION = 'Event'
# LOG_CONFIG_SECTION = 'Log'
# SERVER_CONFIG_SECTION = 'Server'
# MESSENGER_CONFIG_SECTION = 'Messenger'
# REQUEST_PROCESSOR_CONFIG_SECTION = 'RequestProcessor'
# SENDER_CONFIG_SECTION = 'Sender'
# REQUEST_HANDLER_SECTION = 'RequestHandler'
# def init(configuration_file):
# 
# Path: pushkin/util/tools.py
# def is_integer(value):
#     """
#     Checks if a value is of integer type
# 
#     :param value:
#     :return: True if value is integer, False otherwise
#     """
#     try:
#         int(value)
#         return True
#     except ValueError:
#         return False


# Path: pushkin/request/event_handlers.py
from collections import defaultdict
from pushkin.database import database
from pushkin import context
from pushkin import config
from pushkin.util.tools import is_integer
import re

            return parameter

        def get_parameter_map(parametrized_text):
            parameter_names = [key.group(0).strip("{}") for key in
                               PARAM_REGEX.finditer(parametrized_text)]
            parameter_map = {
                param_name: get_parameter(param_name)
                for param_name in parameter_names
            }
            return parameter_map

        raw_messages = []
        if self.event_id == event.event_id:

            filter_platform_id = event_params.get('platform_id')
            if filter_platform_id is not None:
                filter_platform_id = int(filter_platform_id)
            filter_device_token = event_params.get('device_token')
            for message_id in self.message_ids:
                if message_id not in context.message_blacklist.get(event.user_id, set()):
                    try:
                        localized_message = database.get_localized_message(event.user_id, message_id)

                        if localized_message is not None:
                            text_parameter_map = get_parameter_map(localized_message.message_text)
                            title_parameter_map = get_parameter_map(localized_message.message_title)
                            raw_messages.extend(
                                database.get_raw_messages(
                                    login_id=event.user_id, title=localized_message.message_title.encode('utf-8').format(**title_parameter_map).decode('utf-8'),
                                    content=localized_message.message_text.encode('utf-8').format(**text_parameter_map).decode('utf-8'),

                                    screen=localized_message.message.screen, game=config.game, world_id=config.world_id,