Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniospneto committed Jul 21, 2024
1 parent f65aea4 commit 4ca2939
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
9 changes: 7 additions & 2 deletions brazilfiscalreport/dacce/dacce.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (C) 2021-2022 Edson Bernardino <edsones at yahoo.com.br>
# Copyright (C) 2024 Engenere - Antônio S. Pereira Neto <[email protected]>

import warnings
import xml.etree.ElementTree as ET
from io import BytesIO

Expand Down Expand Up @@ -73,7 +74,9 @@ def __init__(self, xml=None, emitente=None, image=None):
self.text(x=123, y=20, text="(Carta de Correção Eletrônica)")

self.set_font("Helvetica", "", 8)
self.text(x=92, y=30, text="ID do Evento: %s" % inf_event.attrib.get("Id")[2:])
self.text(
x=92, y=30, text="ID do Evento: {}".format(inf_event.attrib.get("Id")[2:])
)

dt, hr = get_date_utc(get_tag_text(node=inf_event, url=URL, tag="dhEvento"))

Expand Down Expand Up @@ -113,7 +116,9 @@ def __init__(self, xml=None, emitente=None, image=None):
# Generate a Code128 Barcode as SVG:
svg_img_bytes = BytesIO()
Code128(key, writer=SVGWriter()).write(svg_img_bytes)
self.image(svg_img_bytes, x=127, y=60, w=73, h=15)
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=UserWarning)
self.image(svg_img_bytes, x=127, y=60, w=73, h=15)

self.set_font("Helvetica", "", 7)
self.text(x=130, y=78, text=" ".join(chunks(key, 4)))
Expand Down
5 changes: 4 additions & 1 deletion brazilfiscalreport/danfe/danfe_code.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
from io import BytesIO

from barcode import Code128
Expand All @@ -21,4 +22,6 @@ def render(self):
# Generate a Code128 Barcode as SVG:
svg_img_bytes = BytesIO()
Code128(self.key_nfe, writer=SVGWriter()).write(svg_img_bytes)
self.pdf.image(svg_img_bytes, x=x, y=y, w=w, h=h)
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=UserWarning)
self.pdf.image(svg_img_bytes, x=x, y=y, w=w, h=h)
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def assert_pdf_equal(
"When passing `True` to `generate`"
"a pathlib.Path must be provided as the `expected` parameter"
)
actual_pdf.output(expected.open("wb"), linearize=linearize)
with expected.open("wb") as output_file:
actual_pdf.output(output_file, linearize=linearize)
return
if isinstance(expected, pathlib.Path):
expected_pdf_path = expected
Expand Down

0 comments on commit 4ca2939

Please sign in to comment.