# 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
            )  # Offset for the copyright.

            numbers += 1

    for article in list(data.values()):
        numbers_article += 1

        articles_table["source_%s_number" % numbers_article] = u32(
            source_articles.index(article[8])
        )  # Number for the source.

    header["source_number"] = u32(numbers)  # Number of entries for the source table.

    return source_table


# Locations data table


def make_locations_table(header, locations_data):
    locations_table = {}
    dictionaries.append(locations_table)

    header["locations_offset"] = offset_count()  # Offset for the locations table.

    locations_number = 0

    for loc_coord in list(locations_data.values()):
        locations_table["location_%s_offset" % locations_number] = u32(
            0

# 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

            )  # Offset for the copyright.

            numbers += 1

    for article in list(data.values()):
        numbers_article += 1

        articles_table["source_%s_number" % numbers_article] = u32(
            source_articles.index(article[8])
        )  # Number for the source.

    header["source_number"] = u32(numbers)  # Number of entries for the source table.

    return source_table


# Locations data table


def make_locations_table(header, locations_data):
    locations_table = {}
    dictionaries.append(locations_table)

    header["locations_offset"] = offset_count()  # Offset for the locations table.

    locations_number = 0

    for loc_coord in list(locations_data.values()):
        locations_table["location_%s_offset" % locations_number] = u32(
            0

        )  # Offset for the locations.