Fix: Formateo PEP8 (79 cols) y limpieza flake8 en paquete facho
- Líneas >79 cols reajustadas en todo el paquete - Fix F821: etree.cleanup_namespaces(security) en signature.py (era 'header', NameError) - Fix bug cune_xpath -> xpath en nomina/informacion_general() (NameError) - Elimina clase TaxScheme duplicada en form/__init__.py - Imports explícitos (F403/F405) y __all__ en form_xml/invoice.py, nomina - Elimina imports y variables muertas (F401/F841), E712 (== None -> is None)
This commit is contained in:
@@ -1,23 +1,13 @@
|
||||
from facho import facho
|
||||
|
||||
import zeep
|
||||
from zeep.wsse.username import UsernameToken
|
||||
from .wsse.signature import Signature, BinarySignature
|
||||
from zeep.wsa import WsAddressingPlugin
|
||||
from .wsse.signature import BinarySignature
|
||||
import xmlsec
|
||||
import urllib.request
|
||||
from datetime import datetime
|
||||
from dataclasses import dataclass, asdict, field
|
||||
|
||||
import http.client
|
||||
import hashlib
|
||||
import secrets
|
||||
import base64
|
||||
from dataclasses import dataclass, asdict
|
||||
|
||||
|
||||
__all__ = ['DianClient',
|
||||
'ConsultaResolucionesFacturacionPeticion',
|
||||
'ConsultaResolucionesFacturacionRespuesta']
|
||||
__all__ = ['DianClient']
|
||||
|
||||
|
||||
class SOAPService:
|
||||
|
||||
@@ -33,6 +23,7 @@ class SOAPService:
|
||||
def todict(self):
|
||||
return asdict(self)
|
||||
|
||||
|
||||
@dataclass
|
||||
class GetNumberingRangeResponse:
|
||||
|
||||
@@ -49,7 +40,6 @@ class GetNumberingRangeResponse:
|
||||
|
||||
NumberRangeResponse: list[NumberRangeResponse]
|
||||
|
||||
|
||||
@classmethod
|
||||
def fromdict(cls, data):
|
||||
return cls(
|
||||
@@ -100,6 +90,7 @@ class SendTestSetAsyncResponse:
|
||||
data['ErrorMessageList'] or []
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class SendTestSetAsync(SOAPService):
|
||||
fileName: str
|
||||
@@ -115,6 +106,7 @@ class SendTestSetAsync(SOAPService):
|
||||
def build_response(self, as_dict):
|
||||
return SendTestSetAsyncResponse.fromdict(as_dict)
|
||||
|
||||
|
||||
@dataclass
|
||||
class SendBillSync(SOAPService):
|
||||
fileName: str
|
||||
@@ -129,6 +121,7 @@ class SendBillSync(SOAPService):
|
||||
def build_response(self, as_dict):
|
||||
return as_dict
|
||||
|
||||
|
||||
@dataclass
|
||||
class GetStatusResponse:
|
||||
IsValid: bool
|
||||
@@ -142,12 +135,12 @@ class GetStatusResponse:
|
||||
error_message = data['ErrorMessage']['string']
|
||||
else:
|
||||
error_message = None
|
||||
|
||||
|
||||
return cls(data['IsValid'],
|
||||
data['StatusDescription'],
|
||||
data['StatusCode'],
|
||||
error_message)
|
||||
|
||||
|
||||
|
||||
@dataclass
|
||||
class GetStatus(SOAPService):
|
||||
@@ -162,6 +155,7 @@ class GetStatus(SOAPService):
|
||||
def build_response(self, as_dict):
|
||||
return GetStatusResponse.fromdict(as_dict)
|
||||
|
||||
|
||||
@dataclass
|
||||
class GetStatusZip(SOAPService):
|
||||
trackId: bytes
|
||||
@@ -175,6 +169,7 @@ class GetStatusZip(SOAPService):
|
||||
def build_response(self, as_dict):
|
||||
return GetStatusResponse.fromdict(as_dict[0])
|
||||
|
||||
|
||||
@dataclass
|
||||
class SendNominaSync(SOAPService):
|
||||
contentFile: bytes
|
||||
@@ -188,7 +183,7 @@ class SendNominaSync(SOAPService):
|
||||
def build_response(self, as_dict):
|
||||
return as_dict
|
||||
|
||||
|
||||
|
||||
class Habilitacion:
|
||||
WSDL = 'https://vpfe-hab.dian.gov.co/WcfDianCustomerServices.svc?wsdl'
|
||||
|
||||
@@ -220,6 +215,7 @@ class Habilitacion:
|
||||
def get_wsdl(self):
|
||||
return Habilitacion.WSDL
|
||||
|
||||
|
||||
class DianGateway:
|
||||
|
||||
def _open(self, service):
|
||||
@@ -250,7 +246,11 @@ class DianClient(DianGateway):
|
||||
self._password = password
|
||||
|
||||
def _open(self, service):
|
||||
return zeep.Client(service.get_wsdl(), wsse=UsernameToken(self._username, self._password))
|
||||
return zeep.Client(
|
||||
service.get_wsdl(),
|
||||
wsse=UsernameToken(
|
||||
self._username,
|
||||
self._password))
|
||||
|
||||
|
||||
class DianSignatureClient(DianGateway):
|
||||
@@ -262,13 +262,10 @@ class DianSignatureClient(DianGateway):
|
||||
|
||||
def _open(self, service):
|
||||
# RESOLUCCION 0004: pagina 756
|
||||
from zeep.wsse import utils
|
||||
|
||||
client = zeep.Client(service.get_wsdl(), wsse=
|
||||
BinarySignature(
|
||||
self.private_key_path, self.public_key_path, self.password,
|
||||
signature_method=xmlsec.Transform.RSA_SHA256,
|
||||
digest_method=xmlsec.Transform.SHA256)
|
||||
,
|
||||
client = zeep.Client(service.get_wsdl(), wsse=BinarySignature(
|
||||
self.private_key_path, self.public_key_path, self.password,
|
||||
signature_method=xmlsec.Transform.RSA_SHA256,
|
||||
digest_method=xmlsec.Transform.SHA256),
|
||||
)
|
||||
return client
|
||||
|
||||
Reference in New Issue
Block a user