From b05bd193542c8c58e6c236d6ba16d2dac72c1d1d Mon Sep 17 00:00:00 2001 From: Danimar Ribeiro Date: Fri, 15 Sep 2017 20:56:42 -0300 Subject: [PATCH] Build para windows --- .appveyor.yml | 32 ++++++++++++++++++++++++++++++++ pytrustnfe/nfe/danfe.py | 11 +++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 .appveyor.yml diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 0000000..886484b --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,32 @@ +version: 1.3.{build} + +environment: + matrix: + - python: 35 + - python: 35-x64 + - python: 36 + - python: 36-x64 + +install: + - SET PATH=C:\\Python%PYTHON%;c:\\Python%PYTHON%\\scripts;%PATH% + - python -m pip.__main__ install -U pip wheel setuptools + - pip install -r requirements.txt + +build: off +build_script: + # configure version + - ps: >- + If ($env:APPVEYOR_REPO_TAG -Eq "true" ) { + $version = "$env:APPVEYOR_REPO_TAG_NAME" + } Else { + $version = "$env:APPVEYOR_BUILD_VERSION.dev0" + } + $version | Set-Content version.txt + - python setup.py build bdist_wheel + - ps: Get-ChildItem dist\*.whl | % { pip install $_.FullName } + +test: off +test_script: + - pip list + - py.test -v tests + - ps: Get-ChildItem dist\*.whl | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } diff --git a/pytrustnfe/nfe/danfe.py b/pytrustnfe/nfe/danfe.py index a67d95d..2233877 100644 --- a/pytrustnfe/nfe/danfe.py +++ b/pytrustnfe/nfe/danfe.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # Classe para geração de PDF da DANFE a partir de xml etree.fromstring - +import os from io import BytesIO from textwrap import wrap @@ -20,7 +20,6 @@ from reportlab.pdfbase import pdfmetrics from reportlab.pdfbase.ttfonts import TTFont - def chunks(cString, nLen): for start in range(0, len(cString), nLen): yield cString[start:start+nLen] @@ -75,10 +74,14 @@ def get_image(path, width=1*cm): class danfe(object): def __init__(self, sizepage=A4, list_xml=None, recibo=True, orientation='portrait', logo=None): + + path = os.path.join(os.path.dirname(__file__), 'fonts') pdfmetrics.registerFont( - TTFont('NimbusSanL-Regu', '../fonts/NimbusSanL Regular.ttf')) + TTFont('NimbusSanL-Regu', + os.path.join(path, 'NimbusSanL Regular.ttf'))) pdfmetrics.registerFont( - TTFont('NimbusSanL-Bold', '../fonts/NimbusSanL Bold.ttf')) + TTFont('NimbusSanL-Bold', + os.path.join(path, 'NimbusSanL Bold.ttf'))) self.width = 210 # 21 x 29,7cm self.height = 297 self.nLeft = 10