From 7cd468e20b188326849402062e272355e114e6ce Mon Sep 17 00:00:00 2001 From: Pablo Castellano Date: Sat, 22 Apr 2017 00:58:42 +0200 Subject: [PATCH] =?UTF-8?q?Subo=20FILE=5FVERSION=20y=20muestro=20warning?= =?UTF-8?q?=20cuando=20el=20BORME-JSON=20fue=20generado=20con=20una=20vers?= =?UTF-8?q?i=C3=B3n=20anterior.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bormeparser/borme.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bormeparser/borme.py b/bormeparser/borme.py index 6ae4720..1d8b3f4 100644 --- a/bormeparser/borme.py +++ b/bormeparser/borme.py @@ -48,7 +48,7 @@ # Each new version adds 1 if the result file can change. RAW_FILE_VERSION = "1" # Thousands file version. It represents the file version part corresponding to this parser -TH_FILE_VERSION = "1" +TH_FILE_VERSION = "2" # The file version depends on parser one and parser two. It is coded to avoid # that the parser one changes and the parser two does not. FILE_VERSION = "{}".format(int(RAW_FILE_VERSION) + 1000 * int(TH_FILE_VERSION)) @@ -548,6 +548,9 @@ def set_default(obj): def from_json(self, filename): with open(filename) as fp: d = json.load(fp) + if d["version"] < FILE_VERSION: + logger.warning("This JSON was generated with an older version of bormeparser") + logger.warning("Current version is {0}, file version is {1}.".format(FILE_VERSION, d["version"])) cve = d['cve'] date = datetime.datetime.strptime(d['date'], '%Y-%m-%d').date() seccion = d['seccion'] # TODO: SECCION.from_borme()