# Path: bormeparser/backends/defaults.py
# OPTIONS = {
#     'SANITIZE_COMPANY_NAME': False
# }


import bormeparser
import bormeparser.borme
import argparse
import os
import sys
import time
from common import get_git_revision_short_hash
from bormeparser.backends.defaults import OPTIONS
from threading import Thread
from queue import Queue
        super(ThreadConvertJSON, self).__init__()
        self.queue = queue

    def run(self):
        while True:
            pdf_path, json_path = self.queue.get()
            print('Creating %s ...' % json_path)
            try:
                borme = bormeparser.parse(pdf_path, bormeparser.SECCION.A)
                borme.to_json(json_path)
                print('{cve}: OK'.format(cve=borme.cve))
            except Exception as e:
                print('ERROR: {} ({})'.format(os.path.basename(pdf_path), e))
            self.queue.task_done()


def walk_borme_root(bormes_root, json_root=None):
    pdf_root = os.path.join(bormes_root, 'pdf')
    if json_root is None:
        json_root = os.path.join(bormes_root, 'json')

    _, year_dirs, _ = next(os.walk(pdf_root))
    for year in year_dirs:
        year_dir = os.path.join(pdf_root, year)
        json_year_dir = os.path.join(json_root, year)
        _, month_dirs, _ = next(os.walk(year_dir))
        for month in month_dirs:
            month_dir = os.path.join(year_dir, month)
            json_month_dir = os.path.join(json_year_dir, month)
            _, day_dirs, _ = next(os.walk(month_dir))

# Path: bormeparser/backends/defaults.py
# OPTIONS = {
#     'SANITIZE_COMPANY_NAME': False
# }


# Path: scripts/borme_json_all.py
import bormeparser
import bormeparser.borme
import argparse
import os
import sys
import time
from common import get_git_revision_short_hash
from bormeparser.backends.defaults import OPTIONS
from threading import Thread
from queue import Queue

        super(ThreadConvertJSON, self).__init__()
        self.queue = queue

    def run(self):
        while True:
            pdf_path, json_path = self.queue.get()
            print('Creating %s ...' % json_path)
            try:
                borme = bormeparser.parse(pdf_path, bormeparser.SECCION.A)
                borme.to_json(json_path)
                print('{cve}: OK'.format(cve=borme.cve))
            except Exception as e:
                print('ERROR: {} ({})'.format(os.path.basename(pdf_path), e))
            self.queue.task_done()


def walk_borme_root(bormes_root, json_root=None):
    pdf_root = os.path.join(bormes_root, 'pdf')
    if json_root is None:
        json_root = os.path.join(bormes_root, 'json')

    _, year_dirs, _ = next(os.walk(pdf_root))
    for year in year_dirs:
        year_dir = os.path.join(pdf_root, year)
        json_year_dir = os.path.join(json_root, year)
        _, month_dirs, _ = next(os.walk(year_dir))
        for month in month_dirs:
            month_dir = os.path.join(year_dir, month)
            json_month_dir = os.path.join(json_year_dir, month)
            _, day_dirs, _ = next(os.walk(month_dir))

            for day in day_dirs: