# Path: bormeparser/backends/defaults.py
# OPTIONS = {
#     'SANITIZE_COMPANY_NAME': False
# }
# 
# Path: bormeparser/utils.py
# FIRST_BORME = {2009: datetime.date(2009, 1, 2),
#                2010: datetime.date(2010, 1, 4),
#                2011: datetime.date(2011, 1, 3),
#                2012: datetime.date(2012, 1, 2),
#                2013: datetime.date(2013, 1, 2),
#                2014: datetime.date(2014, 1, 2),
#                2015: datetime.date(2015, 1, 2)}


import bormeparser
import bormeparser.borme
import argparse
import datetime
import os
import time
from bormeparser.backends.defaults import OPTIONS
from bormeparser.utils import FIRST_BORME
from threading import Thread
from queue import Queue
    pdf_day_dir = os.path.join(pdf_root, year, month, day)
    if not os.path.isdir(pdf_day_dir):
        print("No existe {}".format(pdf_day_dir))
        return None, None, None

    _, _, files = next(os.walk(pdf_day_dir))
    for filename in files:
        yield pdf_day_dir, filename


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Convert all BORME PDF files to JSON.')
    parser.add_argument('-d', '--directory', default=BORME_ROOT, help='Directory to download files (default is {})'.format(BORME_ROOT))
    parser.add_argument('-f', '--fromdate', default='today', help='ISO formatted date (ex. 2015-01-01) or "init". Default: today')
    parser.add_argument('-t', '--to', default='today', help='ISO formatted date (ex. 2016-01-01). Default: today')

    args = parser.parse_args()

    if args.fromdate == 'init':
        date_from = FIRST_BORME[2009]
    elif args.fromdate == 'today':
        date_from = datetime.date.today()
    else:
        date_from = datetime.datetime.strptime(args.fromdate, '%Y-%m-%d').date()

    if args.to == 'today':
        date_to = datetime.date.today()
    else:
        date_to = datetime.datetime.strptime(args.to, '%Y-%m-%d').date()


# Path: bormeparser/backends/defaults.py
# OPTIONS = {
#     'SANITIZE_COMPANY_NAME': False
# }
# 
# Path: bormeparser/utils.py
# FIRST_BORME = {2009: datetime.date(2009, 1, 2),
#                2010: datetime.date(2010, 1, 4),
#                2011: datetime.date(2011, 1, 3),
#                2012: datetime.date(2012, 1, 2),
#                2013: datetime.date(2013, 1, 2),
#                2014: datetime.date(2014, 1, 2),
#                2015: datetime.date(2015, 1, 2)}


# Path: scripts/borme_json_date.py
import bormeparser
import bormeparser.borme
import argparse
import datetime
import os
import time
from bormeparser.backends.defaults import OPTIONS
from bormeparser.utils import FIRST_BORME
from threading import Thread
from queue import Queue

    pdf_day_dir = os.path.join(pdf_root, year, month, day)
    if not os.path.isdir(pdf_day_dir):
        print("No existe {}".format(pdf_day_dir))
        return None, None, None

    _, _, files = next(os.walk(pdf_day_dir))
    for filename in files:
        yield pdf_day_dir, filename


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Convert all BORME PDF files to JSON.')
    parser.add_argument('-d', '--directory', default=BORME_ROOT, help='Directory to download files (default is {})'.format(BORME_ROOT))
    parser.add_argument('-f', '--fromdate', default='today', help='ISO formatted date (ex. 2015-01-01) or "init". Default: today')
    parser.add_argument('-t', '--to', default='today', help='ISO formatted date (ex. 2016-01-01). Default: today')

    args = parser.parse_args()

    if args.fromdate == 'init':
        date_from = FIRST_BORME[2009]
    elif args.fromdate == 'today':
        date_from = datetime.date.today()
    else:
        date_from = datetime.datetime.strptime(args.fromdate, '%Y-%m-%d').date()

    if args.to == 'today':
        date_to = datetime.date.today()
    else:
        date_to = datetime.datetime.strptime(args.to, '%Y-%m-%d').date()


    start_time = time.time()