Exemple #1
0
def run():
    """ Run the data builder """
    global settings

    arguments = docopt(__doc__, version=__version__)
    settings['overwrite_database'] = arguments['-f']

    if (not settings['overwrite_database'] 
            and os.path.exists(settings['result_file_path'])):
        out('Output file {f} already exists. Use -f to overwrite.'.format(
            f=settings['result_file_path']
        ), 'error')
        return

    out('Building the database...')
    backup_and_remove(settings['result_file_path'])
    build_stops_database()

    out('Bye!')
def run():
    """ Run the stop line info builder """
    
    arguments = docopt(__doc__, version=__version__)
    settings['overwrite_database'] = arguments['-f']

    stop_line_info_file = os.path.join(
        settings['build_folder'],
        settings['stop_line_info_file']
    )
    if (not settings['overwrite_database']
            and os.path.exists(stop_line_info_file)):
        raise BuildError('Output file {f} already exists. Use -f to overwrite.'.format(
            f=stop_line_info_file
        ))

    out('Build stop name index...')
    name_index = get_line_name_index()
    out('Building stop line info file...')
    backup_and_remove(stop_line_info_file)
    build_stop_line_info_file(stop_line_info_file, name_index)
    out('Done! Bye :)')