Skip to content

Commit

Permalink
Subo FILE_VERSION y muestro warning cuando el BORME-JSON fue generado…
Browse files Browse the repository at this point in the history
… con una versión anterior.
  • Loading branch information
PabloCastellano committed Apr 21, 2017
1 parent 0d49d4c commit 7cd468e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bormeparser/borme.py
Expand Up @@ -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))
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 7cd468e

Please sign in to comment.