Skip to content

Commit

Permalink
* Tolera el caso de intentar escribir un reporte de datasets sobre un…
Browse files Browse the repository at this point in the history
… catálogo que no tiene datasets. Loggea un warning en lugar de levantar una excepción.
  • Loading branch information
abenassi committed Aug 2, 2017
1 parent dea7fc3 commit 6cf6aef
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions HISTORY.md
@@ -1,6 +1,11 @@
History
=======

0.2.21 (2017-08-02)
-------------------

* Tolera el caso de intentar escribir un reporte de datasets sobre un catálogo que no tiene datasets. Loggea un warning en lugar de levantar una excepción.

0.2.20 (2017-08-01)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion pydatajson/__init__.py
Expand Up @@ -9,4 +9,4 @@

__author__ = """Datos Argentina"""
__email__ = 'datos@modernizacion.gob.ar'
__version__ = '0.2.20'
__version__ = '0.2.21'
3 changes: 3 additions & 0 deletions pydatajson/helpers.py
Expand Up @@ -64,6 +64,9 @@ def is_list_of_matching_dicts(list_of_dicts, expected_keys=None):
bool: True si todos los diccionarios comparten sus claves.
"""

if isinstance(list_of_dicts, list) and len(list_of_dicts) == 0:
return False

is_not_list_msg = """
{} no es una lista. Debe ingresar una lista""".format(list_of_dicts)
assert isinstance(list_of_dicts, list), is_not_list_msg
Expand Down
6 changes: 6 additions & 0 deletions pydatajson/writers.py
Expand Up @@ -16,6 +16,7 @@
import json
import unicodecsv as csv
import openpyxl as pyxl
import logging
from . import helpers


Expand All @@ -32,6 +33,11 @@ def write_table(table, path):
assert isinstance(path, (str, unicode)), "`path` debe ser un string"
assert isinstance(table, list), "`table` debe ser una lista de dicts"

# si la tabla está vacía, no escribe nada
if len(table) == 0:
logging.warning("Tabla vacia: no se genera ninguna archivo.")
return

# Sólo sabe escribir listas de diccionarios con información tabular
if not helpers.is_list_of_matching_dicts(table):
raise ValueError("""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -18,7 +18,7 @@

setup(
name='pydatajson',
version='0.2.20',
version='0.2.21',
description="Paquete en python con herramientas para generar y validar metadatos de catálogos de datos en formato data.json.",
long_description=readme + '\n\n' + history,
author="Datos Argentina",
Expand Down

0 comments on commit 6cf6aef

Please sign in to comment.