# Path: esteid/types.py
# class DataFile:
#     def __init__(self, file_name, mimetype, content_type, size, content, info=None):
#         self.file_name = file_name
#         self.mimetype = mimetype
#         self.content_type = content_type
#         self.size = size
#         self.content = content
# 
#         self.info = info


import os
import warnings
from io import BytesIO
from typing import List, Union
from pyasice import Container
from esteid.types import DataFile
def start_esteid_session(request):
    delete_esteid_session(request)
    return {}


def update_esteid_session(request, **kwargs):
    session = request.session
    data = session.get(SESSION_KEY, {})
    data.update(kwargs)
    session[SESSION_KEY] = data  # Django session object requires setting keys explicitly


def delete_esteid_session(request):
    session_data = request.session.pop(SESSION_KEY, {})

    temp_signature_file = session_data.get("temp_signature_file")
    if temp_signature_file:
        try:
            os.unlink(temp_signature_file)
        except OSError:
            pass

    temp_container_file = session_data.get("temp_container_file")
    if temp_container_file:
        try:
            os.unlink(temp_container_file)
        except OSError:
            pass



# Path: esteid/types.py
# class DataFile:
#     def __init__(self, file_name, mimetype, content_type, size, content, info=None):
#         self.file_name = file_name
#         self.mimetype = mimetype
#         self.content_type = content_type
#         self.size = size
#         self.content = content
# 
#         self.info = info


# Path: esteid/session.py
import os
import warnings
from io import BytesIO
from typing import List, Union
from pyasice import Container
from esteid.types import DataFile

def start_esteid_session(request):
    delete_esteid_session(request)
    return {}


def update_esteid_session(request, **kwargs):
    session = request.session
    data = session.get(SESSION_KEY, {})
    data.update(kwargs)
    session[SESSION_KEY] = data  # Django session object requires setting keys explicitly


def delete_esteid_session(request):
    session_data = request.session.pop(SESSION_KEY, {})

    temp_signature_file = session_data.get("temp_signature_file")
    if temp_signature_file:
        try:
            os.unlink(temp_signature_file)
        except OSError:
            pass

    temp_container_file = session_data.get("temp_container_file")
    if temp_container_file:
        try:
            os.unlink(temp_container_file)
        except OSError:
            pass



def open_container(container_path: Union[str, BytesIO] = None, files_to_sign: List[DataFile] = None):