# Path: pyas2/as2utils.py
# def senderrorreport(message, errortext):
# def txtexc(mention_exception_type=True):
# def safe_unicode(value):
#     def __init__(self, msg, *args, **kwargs):
#     def __unicode__(self):
#     def __str__(self):
# def join(*paths):
# def dirshouldbethere(path):
# def opendata(filename, mode, charset=None, errors='strict'):
# def readdata(filename, charset=None, errors='strict'):
# def storefile(targetdir, filename, content, archive):
# def unescape_as2name(ename):
# def escape_as2name(uename):
# def extractpayload(message, **kwargs):
# def mimetostring(msg, headerlen):
# def extractpayload_fromstring1(msg, boundary):
# def extractpayload_fromstring2(msg, boundary):
# def canonicalize2(msg):
# def canonicalize(msg):
# def compress_payload(payload):
# def decompress_payload(payload):
# def encrypt_payload(payload, key, cipher):
# def decrypt_payload(payload, key, passphrase):
# def sign_payload(data, key, passphrase):
# def verify_payload(msg, raw_sig, cert, ca_cert, verify_cert):
# def get_key_passphrase(self):
# def check_binary_sig(signature, boundary, content):
# class AS2Error(Exception):
# class As2Exception(AS2Error):
# class As2DuplicateDocument(AS2Error):
# class As2PartnerNotFound(AS2Error):
# class As2InsufficientSecurity(AS2Error):
# class As2DecompressionFailed(AS2Error):
# class As2DecryptionFailed(AS2Error):
# class As2InvalidSignature(AS2Error):
# class CompressedDataAttr(univ.Sequence):
# class Content(univ.OctetString):
# class CompressedDataPayload(univ.Sequence):
# class CompressedData(univ.Sequence):
# class CompressedDataMain(univ.Sequence):


import logging
import os
import sys
from django.conf import settings
from pyas2 import as2utils
    'INFO': logging.INFO,
    'WARNING': logging.WARNING,
    'ERROR': logging.ERROR,
    'CRITICAL': logging.CRITICAL,
    'STARTINFO': 25
}


def initialize():
    """ Function initializes the global variables for pyAS2 """

    global gsettings
    pyas2_settings = {}
    if hasattr(settings, 'PYAS2'):
        pyas2_settings = settings.PYAS2
    if not gsettings:
        gsettings['environment'] = pyas2_settings.get('ENVIRONMENT', 'production')
        gsettings['port'] = pyas2_settings.get('PORT', 8080)
        gsettings['ssl_certificate'] = pyas2_settings.get('SSLCERTIFICATE', None)
        gsettings['ssl_private_key'] = pyas2_settings.get('SSLPRIVATEKEY', None)
        gsettings['environment_text'] = pyas2_settings.get('ENVIRONMENTTEXT', 'Production')
        gsettings['environment_text_color'] = pyas2_settings.get('ENVIRONMENTTEXTCOLOR', 'Black')
        gsettings['root_dir'] = settings.BASE_DIR
        gsettings['python_path'] = pyas2_settings.get('PYTHONPATH', sys.executable)
        gsettings['managepy_path'] = as2utils.join(settings.BASE_DIR, 'manage.py')
        gsettings['daemon_port'] = pyas2_settings.get('DAEMONPORT', 16388)
        if pyas2_settings.get('DATADIR') and os.path.isdir(pyas2_settings.get('DATADIR')):
            gsettings['root_dir'] = pyas2_settings.get('DATADIR')
        gsettings['payload_receive_store'] = as2utils.join(gsettings['root_dir'], 'messages', '__store', 'payload',
                                                           'received')

# Path: pyas2/as2utils.py
# def senderrorreport(message, errortext):
# def txtexc(mention_exception_type=True):
# def safe_unicode(value):
#     def __init__(self, msg, *args, **kwargs):
#     def __unicode__(self):
#     def __str__(self):
# def join(*paths):
# def dirshouldbethere(path):
# def opendata(filename, mode, charset=None, errors='strict'):
# def readdata(filename, charset=None, errors='strict'):
# def storefile(targetdir, filename, content, archive):
# def unescape_as2name(ename):
# def escape_as2name(uename):
# def extractpayload(message, **kwargs):
# def mimetostring(msg, headerlen):
# def extractpayload_fromstring1(msg, boundary):
# def extractpayload_fromstring2(msg, boundary):
# def canonicalize2(msg):
# def canonicalize(msg):
# def compress_payload(payload):
# def decompress_payload(payload):
# def encrypt_payload(payload, key, cipher):
# def decrypt_payload(payload, key, passphrase):
# def sign_payload(data, key, passphrase):
# def verify_payload(msg, raw_sig, cert, ca_cert, verify_cert):
# def get_key_passphrase(self):
# def check_binary_sig(signature, boundary, content):
# class AS2Error(Exception):
# class As2Exception(AS2Error):
# class As2DuplicateDocument(AS2Error):
# class As2PartnerNotFound(AS2Error):
# class As2InsufficientSecurity(AS2Error):
# class As2DecompressionFailed(AS2Error):
# class As2DecryptionFailed(AS2Error):
# class As2InvalidSignature(AS2Error):
# class CompressedDataAttr(univ.Sequence):
# class Content(univ.OctetString):
# class CompressedDataPayload(univ.Sequence):
# class CompressedData(univ.Sequence):
# class CompressedDataMain(univ.Sequence):


# Path: pyas2/pyas2init.py
import logging
import os
import sys
from django.conf import settings
from pyas2 import as2utils

    'INFO': logging.INFO,
    'WARNING': logging.WARNING,
    'ERROR': logging.ERROR,
    'CRITICAL': logging.CRITICAL,
    'STARTINFO': 25
}


def initialize():
    """ Function initializes the global variables for pyAS2 """

    global gsettings
    pyas2_settings = {}
    if hasattr(settings, 'PYAS2'):
        pyas2_settings = settings.PYAS2
    if not gsettings:
        gsettings['environment'] = pyas2_settings.get('ENVIRONMENT', 'production')
        gsettings['port'] = pyas2_settings.get('PORT', 8080)
        gsettings['ssl_certificate'] = pyas2_settings.get('SSLCERTIFICATE', None)
        gsettings['ssl_private_key'] = pyas2_settings.get('SSLPRIVATEKEY', None)
        gsettings['environment_text'] = pyas2_settings.get('ENVIRONMENTTEXT', 'Production')
        gsettings['environment_text_color'] = pyas2_settings.get('ENVIRONMENTTEXTCOLOR', 'Black')
        gsettings['root_dir'] = settings.BASE_DIR
        gsettings['python_path'] = pyas2_settings.get('PYTHONPATH', sys.executable)
        gsettings['managepy_path'] = as2utils.join(settings.BASE_DIR, 'manage.py')
        gsettings['daemon_port'] = pyas2_settings.get('DAEMONPORT', 16388)
        if pyas2_settings.get('DATADIR') and os.path.isdir(pyas2_settings.get('DATADIR')):
            gsettings['root_dir'] = pyas2_settings.get('DATADIR')
        gsettings['payload_receive_store'] = as2utils.join(gsettings['root_dir'], 'messages', '__store', 'payload',
                                                           'received')

        gsettings['payload_send_store'] = as2utils.join(gsettings['root_dir'], 'messages', '__store', 'payload', 'sent')