# Path: src/sii/lib/lib/xml.py
# XML_DECL = lambda enc: b'<?xml version="1.0" encoding="' + bytes(enc, enc) + b'"?>'
# class XML(object):
#     def __init__(self, node=None, name=None, text=None, namespaces=None):
#     def __repr__(self):
#     def __str__(self):
#     def __int__(self):
#     def __float__(self):
#     def __iter__(self):
#     def __setattr__(self, name, value):
#     def __getitem__(self, key):
#     def __setitem__(self, key, value):
#     def __remove__(self):
#     def __name__(self):
#     def __children__(self):
#     def __siblings__(self):
#     def __generation__(self):
#     def _etree(self):
#     def _xml(self):
#     def _str(self):
#     def _int(self):
#     def _float(self):
#     def _number(self):
#     def _list(self):
#     def _has(self, name):
# def create_xml(name, value=None, namespaces=None):
# def read_xml(path):
# def load_xml(xml_string):
# def wrap_xml(xml_etree):
# def dump_etree(xml_node):
# def dump_xml(xml_node, **kwargs):
# def print_xml(xml, file=sys.stdout.buffer, end='\n', encoding='UTF-8'):
# def write_xml(xml, fpath, end='\n', encoding='UTF-8', append=False):


import re
import copy
import base64
import datetime as dt
from Crypto.Signature import PKCS1_v1_5
from Crypto.Hash      import SHA as SHA1
from Crypto.PublicKey import RSA
from .lib import xml
""" Creation and management of SII Digital Stamp Utilities
"""




def build_digital_stamp(doc_xml, caf_xml):
    """ Builds a digital stamp digest from a DTE.

    :param `etree.Element` doc_xml: DTE Document node.
    :param `etree.Element` caf_xml: Codigo autorizacion de folios XML.

    :return: `etree.Element` of the 'TED' (Timbre Electronico Digital?) node.
    """

# Path: src/sii/lib/lib/xml.py
# XML_DECL = lambda enc: b'<?xml version="1.0" encoding="' + bytes(enc, enc) + b'"?>'
# class XML(object):
#     def __init__(self, node=None, name=None, text=None, namespaces=None):
#     def __repr__(self):
#     def __str__(self):
#     def __int__(self):
#     def __float__(self):
#     def __iter__(self):
#     def __setattr__(self, name, value):
#     def __getitem__(self, key):
#     def __setitem__(self, key, value):
#     def __remove__(self):
#     def __name__(self):
#     def __children__(self):
#     def __siblings__(self):
#     def __generation__(self):
#     def _etree(self):
#     def _xml(self):
#     def _str(self):
#     def _int(self):
#     def _float(self):
#     def _number(self):
#     def _list(self):
#     def _has(self, name):
# def create_xml(name, value=None, namespaces=None):
# def read_xml(path):
# def load_xml(xml_string):
# def wrap_xml(xml_etree):
# def dump_etree(xml_node):
# def dump_xml(xml_node, **kwargs):
# def print_xml(xml, file=sys.stdout.buffer, end='\n', encoding='UTF-8'):
# def write_xml(xml, fpath, end='\n', encoding='UTF-8', append=False):


# Path: src/sii/lib/stamping.py
import re
import copy
import base64
import datetime as dt
from Crypto.Signature import PKCS1_v1_5
from Crypto.Hash      import SHA as SHA1
from Crypto.PublicKey import RSA
from .lib import xml

""" Creation and management of SII Digital Stamp Utilities
"""




def build_digital_stamp(doc_xml, caf_xml):
    """ Builds a digital stamp digest from a DTE.

    :param `etree.Element` doc_xml: DTE Document node.
    :param `etree.Element` caf_xml: Codigo autorizacion de folios XML.

    :return: `etree.Element` of the 'TED' (Timbre Electronico Digital?) node.
    """

    caf = xml.wrap_xml(caf_xml)