Skip to content

Commit

Permalink
JSON: Nuevos campos "version" y "raw_version"
Browse files Browse the repository at this point in the history
Proporciona compatibilidad con otros parsers como yabormeparser
  • Loading branch information
PabloCastellano committed Sep 2, 2016
1 parent 4ae549e commit 3712842
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bormeparser/borme.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@
logger.addHandler(ch)
logger.setLevel(logging.WARN)

# RAW_FILE_VERSION must be a positive integer string.
# 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"
# 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))


class BormeActo(object):
"""
Expand Down Expand Up @@ -499,6 +508,11 @@ def _to_dict(self, set_url=True):
doc['anuncios'][anuncio.id]['actos'][acto.name] = acto.value

doc['num_anuncios'] = num_anuncios

# For compatibility with other parsers
doc['raw_version'] = RAW_FILE_VERSION
doc['version'] = FILE_VERSION

logger.debug(doc)
return doc

Expand Down
1 change: 1 addition & 0 deletions scripts/borme_json_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

THREADS = 6


class ThreadConvertJSON(Thread):
def __init__(self, queue):
super(ThreadConvertJSON, self).__init__()
Expand Down

0 comments on commit 3712842

Please sign in to comment.