# Path: utils.py
# def setup_log(sentry_url, print_errors):
#     global logger, production
#     sentry_logging = LoggingIntegration(
#         level=logging.INFO,
#         event_level=logging.INFO
#     )
#     sentry_sdk.init(dsn=sentry_url, integrations=[sentry_logging])
#     logger = logging.getLogger(__name__)
#     p_errors = print_errors
#     production = True
# 
# def log(msg, level):  # TODO: Use number levels, strings are annoying
#     if p_errors:
#         print(msg)
# 
#     if production:
#         if level == "VERBOSE":
#             logger.debug(msg)
#         elif level == "INFO":
#             logger.info(msg)
#         elif level == "WARNING":
#             logger.warning(msg)
#         elif level == "CRITICAL":
#             logger.critical(msg)
# 
# def u8(data):
#     if not 0 <= data <= 255:
#         log("u8 out of range: %s" % data, "INFO")
#         data = 0
#     return struct.pack(">B", data)
# 
# def u16(data):
#     if not 0 <= data <= 65535:
#         log("u16 out of range: %s" % data, "INFO")
#         data = 0
#     return struct.pack(">H", data)
# 
# def u32(data):
#     if not 0 <= data <= 4294967295:
#         log("u32 out of range: %s" % data, "INFO")
#         data = 0
#     return struct.pack(">I", data)


import binascii
import calendar
import CloudFlare
import datetime
import json
import logging
import nlzss
import os
import struct
import subprocess
import sys
import textwrap
import time
import MySQLdb
import requests
import rsa
from utils import setup_log, log, u8, u16, u32
from Channels.Everybody_Votes_Channel.voteslists import *
            worldwide_question_table["poll_id_%s" % num()] = u32(q)
            worldwide_question_table["poll_category_1_%s" % num()] = u8(get_category(q))
            worldwide_question_table["poll_category_2_%s" % num()] = u8(categories[get_category(q)])
            worldwide_question_table["opening_timestamp_%s" % num()] = u32(get_timestamp(1, "w", get_date(q)))
            worldwide_question_table["closing_timestamp_%s" % num()] = u32(get_timestamp(2, "w", get_date(q)))
            worldwide_question_table["question_table_count_%s" % num()] = u8(question_table_count)
            worldwide_question_table["question_table_start_%s" % num()] = u32(question_table_start)
            question_table_count += 1

    return worldwide_question_table


def make_question_text_table(header):
    global questions
    question_text_table = collections.OrderedDict()
    dictionaries.append(question_text_table)

    header["question_offset"] = offset_count()

    for q in question_keys:
        if get_type(q) == "w":
            if file_type == "v":
                poll_list = country_language[country_code]
            elif file_type == "q":
                poll_list = list(range(1, 9))
        elif get_type(q) == "n":
            poll_list = country_language[country_code]
        for language_code in poll_list:
            if get_question(q, language_code) is not None:
                num = question_keys.index(q)

# Path: utils.py
# def setup_log(sentry_url, print_errors):
#     global logger, production
#     sentry_logging = LoggingIntegration(
#         level=logging.INFO,
#         event_level=logging.INFO
#     )
#     sentry_sdk.init(dsn=sentry_url, integrations=[sentry_logging])
#     logger = logging.getLogger(__name__)
#     p_errors = print_errors
#     production = True
# 
# def log(msg, level):  # TODO: Use number levels, strings are annoying
#     if p_errors:
#         print(msg)
# 
#     if production:
#         if level == "VERBOSE":
#             logger.debug(msg)
#         elif level == "INFO":
#             logger.info(msg)
#         elif level == "WARNING":
#             logger.warning(msg)
#         elif level == "CRITICAL":
#             logger.critical(msg)
# 
# def u8(data):
#     if not 0 <= data <= 255:
#         log("u8 out of range: %s" % data, "INFO")
#         data = 0
#     return struct.pack(">B", data)
# 
# def u16(data):
#     if not 0 <= data <= 65535:
#         log("u16 out of range: %s" % data, "INFO")
#         data = 0
#     return struct.pack(">H", data)
# 
# def u32(data):
#     if not 0 <= data <= 4294967295:
#         log("u32 out of range: %s" % data, "INFO")
#         data = 0
#     return struct.pack(">I", data)


# Path: Channels/Everybody_Votes_Channel/votes.py
import binascii
import calendar
import CloudFlare
import datetime
import json
import logging
import nlzss
import os
import struct
import subprocess
import sys
import textwrap
import time
import MySQLdb
import requests
import rsa
from utils import setup_log, log, u8, u16, u32
from Channels.Everybody_Votes_Channel.voteslists import *

            worldwide_question_table["poll_id_%s" % num()] = u32(q)
            worldwide_question_table["poll_category_1_%s" % num()] = u8(get_category(q))
            worldwide_question_table["poll_category_2_%s" % num()] = u8(categories[get_category(q)])
            worldwide_question_table["opening_timestamp_%s" % num()] = u32(get_timestamp(1, "w", get_date(q)))
            worldwide_question_table["closing_timestamp_%s" % num()] = u32(get_timestamp(2, "w", get_date(q)))
            worldwide_question_table["question_table_count_%s" % num()] = u8(question_table_count)
            worldwide_question_table["question_table_start_%s" % num()] = u32(question_table_start)
            question_table_count += 1

    return worldwide_question_table


def make_question_text_table(header):
    global questions
    question_text_table = collections.OrderedDict()
    dictionaries.append(question_text_table)

    header["question_offset"] = offset_count()

    for q in question_keys:
        if get_type(q) == "w":
            if file_type == "v":
                poll_list = country_language[country_code]
            elif file_type == "q":
                poll_list = list(range(1, 9))
        elif get_type(q) == "n":
            poll_list = country_language[country_code]
        for language_code in poll_list:
            if get_question(q, language_code) is not None:
                num = question_keys.index(q)

                question_text_table["language_code_%s_%s" % (num, language_code)] = u8(language_code)