Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage pyfepdf #71

Merged
merged 11 commits into from
Aug 11, 2021
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ omit =
*nsis*
*/padron.py
*pyemail*
*pyfepdf*
*formatos*
chazuttu marked this conversation as resolved.
Show resolved Hide resolved
*pyi25*
*pyqr*
*rece1*
Expand Down
10 changes: 5 additions & 5 deletions conf/rece.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# EJEMPLO de archivo de configuraci�n de la interfaz PyAfipWs
# EJEMPLO de archivo de configuraci�n de la interfaz PyAfipWs
# DEBE CAMBIAR Certificado (CERT) y Clave Privada (PRIVATEKEY)
# Para producci�n debe descomentar las URL (sacar ##)
# M�s informaci�n:
# http://www.sistemasagiles.com.ar/trac/wiki/ManualPyAfipWs#Configuraci�n
# Para producci�n debe descomentar las URL (sacar ##)
# M�s informaci�n:
# http://www.sistemasagiles.com.ar/trac/wiki/ManualPyAfipWs#Configuraci�n

[WSAA]
CERT=reingart.crt
Expand Down Expand Up @@ -78,7 +78,7 @@ LOCALE=Spanish_Argentina.1252
FMT_CANTIDAD=0.4
FMT_PRECIO=0.3
CANT_POS=izq
ENTRADA=factura.txt
ENTRADA=datos/facturas.txt
SALIDA=factura.pdf

[PDF]
Expand Down
17 changes: 17 additions & 0 deletions formatos/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/python
# -*- coding: utf8 -*-
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
# for more details.

"""Módulo para acceder a web services de la afip
"""
__author__ = "Mariano Reingart (mariano@gmail.com)"
__copyright__ = "Copyright (C) 2008-2021 Mariano Reingart"
__license__ = "LGPL-3.0-or-later"
2 changes: 1 addition & 1 deletion formatos/formato_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ def escribir(filas, fn="salida.json"):
jsonfile,
sort_keys=True,
indent=4,
encoding="utf-8",
# encoding="utf-8",
chazuttu marked this conversation as resolved.
Show resolved Hide resolved
)
jsonfile.close()
8 changes: 5 additions & 3 deletions formatos/formato_txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
__license__ = "LGPL-3.0-or-later"

from decimal import Decimal
import sys

CHARSET = "latin1"

Expand Down Expand Up @@ -229,8 +230,9 @@ def escribir_linea_txt(dic, formato):
valor = dic.get(clave, "")
if not isinstance(valor, basestring):
valor = str(valor)
if isinstance(valor, str):
valor = valor.encode(CHARSET, "replace")
if sys.version_info[0] < 3 :
if isinstance(valor, str):
valor = valor.encode(CHARSET, "replace")
if valor == "None":
valor = ""
if tipo == N and valor and valor != "NULL":
Expand All @@ -257,7 +259,7 @@ def escribir_linea_txt(dic, formato):

def leer(fn="entrada.txt"):
"Analiza un archivo TXT y devuelve un diccionario"
f_entrada = open(fn, "r")
f_entrada = open(fn, "rb")
chazuttu marked this conversation as resolved.
Show resolved Hide resolved
try:
regs = []
reg = None
Expand Down
6 changes: 3 additions & 3 deletions pyfepdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

DEBUG = False
HOMO = False
CONFIG_FILE = "rece.ini"
CONFIG_FILE = "conf/rece.ini"
chazuttu marked this conversation as resolved.
Show resolved Hide resolved

LICENCIA = u"""
pyfepdf.py: Interfaz para generar Facturas Electrónica en formato PDF
Expand Down Expand Up @@ -1651,7 +1651,7 @@ def GenerarPDF(self, archivo=""):

@utils.inicializar_y_capturar_excepciones_simple
def MostrarPDF(self, archivo, imprimir=False):
if sys.platform.startswith(("linux2", "java")):
if sys.platform.startswith(("linux2", "java", "linux")):
os.system("evince " "%s" "" % archivo)
else:
operation = imprimir and "print" or ""
Expand Down Expand Up @@ -2037,7 +2037,7 @@ def main():
elif "--json" in sys.argv:
from .formatos import formato_json

archivo = conf_fact.get("entrada", "entrada.txt")
archivo = "salida.json"
chazuttu marked this conversation as resolved.
Show resolved Hide resolved
if DEBUG:
print("Escribiendo", archivo)
regs = formato_json.escribir([reg], archivo)
Expand Down
2 changes: 1 addition & 1 deletion pyqr.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def GenerarImagen(

# convertir a representación json y codificar en base64:
datos_cmp_json = json.dumps(datos_cmp)
url = self.URL % (base64.b64encode(datos_cmp_json))
url = self.URL % (base64.b64encode(datos_cmp_json.encode('ascii')))

qr = qrcode.QRCode(
version=self.qr_ver,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"(soap, com/dll, pdf, dbf, xml, etc.)"
)
kwargs["package_dir"] = {"pyafipws": "."}
kwargs["packages"] = ["pyafipws"]
kwargs["packages"] = ["pyafipws", "pyafipws.formatos"]
opts = {}
data_files = [("pyafipws/plantillas", glob.glob("plantillas/*"))]

Expand Down
Loading