comentarios, se remueve requirements_dev.txt

FossilOrigin-Name: 22450fbe7fb9f02c4723c2820d9b7bc3e0d7018a4cb900bdc4f6867e4550951f
This commit is contained in:
bit4bit 2022-02-12 00:28:49 +00:00
parent 48c56631ec
commit a9564f9a70
3 changed files with 15 additions and 23 deletions

View File

@ -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():

View File

@ -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

View File

@ -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",