Skip to content

Commit

Permalink
CHANGELOG.md update
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas-C committed Aug 22, 2021
1 parent 247d045 commit 24c2bab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and [PEP 440](https://www.python.org/dev/peps/pep-0440/).
- `fpdf.FPDF()` constructor now accepts ints or floats as a unit, and raises a `ValueError` if an invalid unit is provided.

### Fixed
- `Template.parse_csv`: preserving numeric values when using CSV based templates - [#205](https://github.com/PyFPDF/fpdf2/pull/205)
- the code snippet to generate Code 39 barcodes in the documentation was missing the start & end `*` characters.
This has been fixed, and a warning is now triggered by the [`FPDF.code39`](https://pyfpdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.code39) method when those characters are missing.

Expand Down
7 changes: 4 additions & 3 deletions fpdf/util.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import locale
from typing import Union, Iterable

try_to_type_known_types = [
_TRY_TO_TYPE_KNOWN_TYPES = (
int,
float,
]
)


def try_to_type(value):
for known_type in try_to_type_known_types:
"Try to convert a string into a number"
for known_type in _TRY_TO_TYPE_KNOWN_TYPES:
try:
return known_type(value)
except ValueError:
Expand Down
6 changes: 2 additions & 4 deletions test/template/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,11 @@ def test_template_nominal_csv(tmp_path):
tmpl = Template(format="A4", title="Sample Invoice")
tmpl.parse_csv(HERE / "mycsvfile.csv", delimiter=";")
tmpl.add_page()
tmpl.render()
assert_pdf_equal(tmpl.pdf, HERE / "template_nominal_csv.pdf", tmp_path)
assert_pdf_equal(tmpl, HERE / "template_nominal_csv.pdf", tmp_path)
tmpl = Template(format="A4", title="Sample Invoice")
tmpl.parse_csv(HERE / "mycsvfile.csv", delimiter=";", encoding="utf-8")
tmpl.add_page()
tmpl.render()
assert_pdf_equal(tmpl.pdf, HERE / "template_nominal_csv.pdf", tmp_path)
assert_pdf_equal(tmpl, HERE / "template_nominal_csv.pdf", tmp_path)


def test_template_code39(tmp_path): # issue-161
Expand Down

0 comments on commit 24c2bab

Please sign in to comment.