Skip to content

Commit

Permalink
JSON: campos "version" y "raw_version" para compatibilidad con otros …
Browse files Browse the repository at this point in the history
…parsers como yabormeparser
  • Loading branch information
PabloCastellano committed Sep 2, 2016
1 parent 4ae549e commit 1caba5b
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 @@ -475,6 +484,11 @@ def download(self, filename):

def _to_dict(self, set_url=True):
doc = OrderedDict()

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

doc['cve'] = self.cve
doc['date'] = self.date.isoformat()
doc['seccion'] = self.seccion
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 1caba5b

Please sign in to comment.