From a9564f9a7002116da623cc34745554550d9042e9 Mon Sep 17 00:00:00 2001 From: bit4bit Date: Sat, 12 Feb 2022 00:28:49 +0000 Subject: [PATCH] comentarios, se remueve requirements_dev.txt FossilOrigin-Name: 22450fbe7fb9f02c4723c2820d9b7bc3e0d7018a4cb900bdc4f6867e4550951f --- facho/fe/fe.py | 22 ++++++++++++++-------- requirements_dev.txt | 13 ------------- setup.py | 3 +-- 3 files changed, 15 insertions(+), 23 deletions(-) delete mode 100644 requirements_dev.txt diff --git a/facho/fe/fe.py b/facho/fe/fe.py index c539c43..d082b39 100644 --- a/facho/fe/fe.py +++ b/facho/fe/fe.py @@ -79,20 +79,17 @@ class FeXML(FachoXML): super().__init__("{%s}%s" % (namespace, root), nsmap=NAMESPACES) - self._cn = root.rstrip('/') - #self.find_or_create_element(self._cn) - @classmethod def from_string(cls, document: str) -> 'FeXML': return super().from_string(document, namespaces=NAMESPACES) def tostring(self, **kw): + # MACHETE(bit4bit) la DIAN espera que la etiqueta raiz no este en un namespace return super().tostring(**kw)\ .replace("fe:", "")\ .replace("xmlns:fe", "xmlns") - class DianXMLExtensionCUDFE(FachoXMLExtension): def __init__(self, invoice, tipo_ambiente = AMBIENTE_PRUEBAS): @@ -463,10 +460,18 @@ class DianZIP: return filename + # DEPRECATED usar add_xml def add_invoice_xml(self, name, xml_data): return self.add_xml(name, xml_data) def __enter__(self): + """ + Facilita el uso de esta manera: + + f = open('xxx', 'rb') + with DianZIP(f) as zip: + zip.add_invoice_xml('name', 'data xml') + """ return self def __exit__(self, type, value, traceback): @@ -483,24 +488,25 @@ class DianXMLExtensionSignerVerifier: self._passphrase = passphrase.encode('utf-8') def verify_string(self, document): + # Obtener FachoXML xml = LXMLBuilder.from_string(document) fachoxml = FachoXML(xml,nsmap=NAMESPACES) + # Obtener Signature signature = fachoxml.builder.xpath(fachoxml.root, '//ds:Signature') assert signature is not None + # Se mueve Signature a elemento raiz para realizar verificaion signature.getparent().remove(signature) fachoxml.root.append(signature) - ctx = xades.XAdESContext() - + # Verificar archivo usando Signature pkcs12_data = self._pkcs12_path_or_bytes if isinstance(self._pkcs12_path_or_bytes, str): pkcs12_data = open(self._pkcs12_path_or_bytes, 'rb').read() - + ctx = xades.XAdESContext() ctx.load_pkcs12(OpenSSL.crypto.load_pkcs12(pkcs12_data, self._passphrase)) - try: if self._mockpolicy: with mock_xades_policy(): diff --git a/requirements_dev.txt b/requirements_dev.txt deleted file mode 100644 index f17ffa4..0000000 --- a/requirements_dev.txt +++ /dev/null @@ -1,13 +0,0 @@ -pip==18.1 -bumpversion==0.5.3 -wheel==0.32.1 -watchdog==0.9.0 -flake8==3.5.0 -tox==3.5.2 -coverage==4.5.1 -Sphinx==1.8.1 -twine==1.12.1 -xmlsec==1.3.8 - -pytest==3.8.2 -pytest-runner==4.2 diff --git a/setup.py b/setup.py index f10115d..de5ac78 100644 --- a/setup.py +++ b/setup.py @@ -20,13 +20,12 @@ requirements = ['Click>=6.0', 'pyOpenSSL==20.0.1', 'xmlsig==0.1.7', 'xades==0.2.2', - 'mock>=2.0.0', 'xmlsec==1.3.12', 'xmlschema>=1.8'] setup_requirements = ['pytest-runner', ] -test_requirements = ['pytest', ] +test_requirements = ['pytest', 'mock>=2.0.0'] setup( author="Jovany Leandro G.C",