diff --git a/.gitignore b/.gitignore index af4f1e7c..b9882f6b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,8 @@ # Linux .*.swp +poetry.lock + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/pynfe/utils/descompactar.py b/pynfe/utils/descompactar.py index 61d14172..32c7d330 100644 --- a/pynfe/utils/descompactar.py +++ b/pynfe/utils/descompactar.py @@ -5,7 +5,6 @@ """ -from io import BytesIO import base64 import gzip from lxml import etree @@ -13,18 +12,12 @@ class DescompactaGzip(object): @staticmethod - def descompacta(stringZipada): + def descompacta(stringZipada: str): """ :paramn stringZipada: String :return : Etree """ - arq = BytesIO() - arq.write(base64.b64decode(stringZipada)) - arq.seek(0) - zip = gzip.GzipFile(fileobj=arq) - texto = zip.read() - arq.close() - zip.close() - descompactado = texto.decode("utf-8").encode() - return etree.fromstring(descompactado) + decoded = base64.b64decode(stringZipada) + decompress_nfe = gzip.decompress(decoded).decode("utf8") + return etree.fromstring(decompress_nfe) diff --git a/pyproject.toml b/pyproject.toml index 6ed99424..2f56a155 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,46 @@ +[project] +name = "PyNFe" +version = "0.4.4" +description = "Interface library with the Brazilian Electronic Invoice web services" +authors = [ + {name = "TadaSoftware",email = " tadasoftware@gmail.com"} +] +readme = "README.md" +requires-python = ">=3.9, <4" + + [build-system] requires = ["setuptools>=42"] build-backend = "setuptools.build_meta" + [tool.ruff] exclude = [ 'pynfe/entidades/__init__.py' ] -line-length = 100 \ No newline at end of file +line-length = 100 + +[tool.poetry.dependencies] +requests = "^2.32.4" +signxml = "^4.1.0" +cryptography = "43.0.3" +lxml = "5.4.0" +pyopenssl = "^25.1.0" + +[tool.poetry.group.dev.dependencies] +ruff = "^0.12.5" +pytest = "^8.4.1" +taskipy = "^1.14.1" +pytest-cov = "^6.2.1" + +[tool.pytest.ini_options] +pythonpath = "." +addopts = '-p no:warnings' + +[tool.taskipy.tasks] +lint = 'ruff check' +pre_format = 'ruff check --fix' +format = 'ruff format' +pre_lint = 'task format' +pre_test = 'task lint' +test = 'pytest -s -x --cov=app -vv' +post_test = 'coverage html'