Additonal arguments are passed to barnehagefakta_get_json"""
    j = barnehagefakta_get_json(nbr_id, *args, **kwargs)
    if j is None:
        return {}
    elif j == '404':
        raise NotFoundException('nbr_id={0} returned 404'.format(nbr_id))
    #return {}
    
    dct = json.loads(j)
    if logger.isEnabledFor(logging.DEBUG):
        logger.debug('barnehagefakta_get(%s) -> %s', nbr_id, pretty_printer.pformat(dct))
    return dct

if __name__ == '__main__':
    import argparse_util
    parser = argparse_util.get_parser('Helper script for requesting (with local cache) and parsing json data from "Utdanningdsdirektoratet Nasjonalt barnehageregister (NBR)"')
    parser.add_argument('nbr_id', nargs='+', help='Unique NBR-id(s) to download (e.g. 1015988).')
    parser.add_argument('--cache_dir', default='data',
                        help='Specify directory for cached .json files, defaults to data/')
    argparse_util.add_verbosity(parser, default=logging.DEBUG)
    
    args = parser.parse_args()

    logging.basicConfig(level=args.loglevel)    

    if args.nbr_id:             # list of ids given
        for nbr_id in args.nbr_id:
            print 'Getting', nbr_id
            barnehagefakta_get(nbr_id, cache_dir=args.cache_dir)

    print len(osm.nsrids), osm.nsrids
    return osm

if __name__ == '__main__':
    import argparse_util
    parser = argparse_util.get_parser('Looks for <data_dir>/<kommune_id>/*.osm files and generates html for http://obtitus.github.io/barnehagefakta_osm_data/. The site is generated in the current directory by default and assumes template.html and index_template.html exists in the current directory.')
    parser.add_argument('--data_dir', default='data',
                        help='Specify directory for .osm files, defaults to data/')
    parser.add_argument('--output_dir', default='.',
                        help="Specify output directory, defaults to current directory")        
    parser.add_argument('--template', default='template.html',
                        help="Specify template file for each of the kommune pages, defaults to template.html")
    parser.add_argument('--index_template', default='index_template.html',
                        help="Specify template file for index.html, defaults to index_template.html")
    parser.add_argument('--no-overpass', default=False, action='store_true',
                        help="Do not call the openstreetmap overpass api looking for no-barnehage:nsrid")
    argparse_util.add_verbosity(parser, default=logging.WARNING)

    args = parser.parse_args()
    
    logging.basicConfig(level=args.loglevel)

    if args.no_overpass:
        osm = None
    else:
        osm = get_osm_data()
    
    main(osm, args.data_dir,
         template=args.template, index_template=args.index_template,
         root_output=args.output_dir)