# 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 mkdir_p(path):
#     try:
#         os.makedirs(path)
#     except:
#         pass
# 
# 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)
# 
# def u32_littleendian(data):
#     if not 0 <= data <= 4294967295:
#         log("u32 little endian out of range: %s" % data, "INFO")
#         data = 0
#     return struct.pack("<I", data)


import binascii
import calendar
import CloudFlare
import difflib
import glob
import json
import nlzss
import os
import pickle
import requests
import subprocess
import sys
import time
import utils
import rsa
from datetime import timedelta, datetime, date
from . import newsdownload
from datadog import statsd
from utils import setup_log, log, mkdir_p, u8, u16, u32, u32_littleendian
        numbers += 1

        header["language_select_%s" % numbers] = u8(language)

    # Fills the rest of the languages as null

    while numbers < 16:
        numbers += 1

        header["language_select_%s" % numbers] = u8(255)

    header["language_code"] = u8(language_code)  # Wii language code.
    header["goo_flag"] = u8(0)  # Flag to make the Globe display "Powered by Goo".
    header["language_select_screen_flag"] = u8(
        0
    )  # Flag to bring up the language select screen.
    header["download_interval"] = u8(
        30
    )  # Interval in minutes to check for new articles to display on the Wii Menu.
    header["message_offset"] = u32(0)  # Offset for a message.
    header["topics_number"] = u32(0)  # Number of entries for the topics table.
    header["topics_offset"] = u32(0)  # Offset for the topics table.
    header["articles_number"] = u32(0)  # Number of entries for the articles table.
    header["articles_offset"] = u32(0)  # Offset for the articles table.
    header["source_number"] = u32(0)  # Number of entries for the source table.
    header["source_offset"] = u32(0)  # Offset for the source table.
    header["locations_number"] = u32(0)  # Number of entries for the locations.
    header["locations_offset"] = u32(0)  # Offset for the locations table.
    header["pictures_number"] = u32(0)  # Number of entries for the pictures table.
    header["pictures_offset"] = u32(0)  # Offset for the pictures table.

# 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 mkdir_p(path):
#     try:
#         os.makedirs(path)
#     except:
#         pass
# 
# 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)
# 
# def u32_littleendian(data):
#     if not 0 <= data <= 4294967295:
#         log("u32 little endian out of range: %s" % data, "INFO")
#         data = 0
#     return struct.pack("<I", data)


# Path: Channels/News_Channel/newsmake.py
import binascii
import calendar
import CloudFlare
import difflib
import glob
import json
import nlzss
import os
import pickle
import requests
import subprocess
import sys
import time
import utils
import rsa
from datetime import timedelta, datetime, date
from . import newsdownload
from datadog import statsd
from utils import setup_log, log, mkdir_p, u8, u16, u32, u32_littleendian

        numbers += 1

        header["language_select_%s" % numbers] = u8(language)

    # Fills the rest of the languages as null

    while numbers < 16:
        numbers += 1

        header["language_select_%s" % numbers] = u8(255)

    header["language_code"] = u8(language_code)  # Wii language code.
    header["goo_flag"] = u8(0)  # Flag to make the Globe display "Powered by Goo".
    header["language_select_screen_flag"] = u8(
        0
    )  # Flag to bring up the language select screen.
    header["download_interval"] = u8(
        30
    )  # Interval in minutes to check for new articles to display on the Wii Menu.
    header["message_offset"] = u32(0)  # Offset for a message.
    header["topics_number"] = u32(0)  # Number of entries for the topics table.
    header["topics_offset"] = u32(0)  # Offset for the topics table.
    header["articles_number"] = u32(0)  # Number of entries for the articles table.
    header["articles_offset"] = u32(0)  # Offset for the articles table.
    header["source_number"] = u32(0)  # Number of entries for the source table.
    header["source_offset"] = u32(0)  # Offset for the source table.
    header["locations_number"] = u32(0)  # Number of entries for the locations.
    header["locations_offset"] = u32(0)  # Offset for the locations table.
    header["pictures_number"] = u32(0)  # Number of entries for the pictures table.
    header["pictures_offset"] = u32(0)  # Offset for the pictures table.

    header["count"] = u16(480)  # Count value.