Пример #1
0
    parser.add_argument('-hn', '--house_number', type=str, action='store')
    parser.add_argument('-p', '--path', type=str, action='store',
                        help="path to save downloaded data")
    parser.add_argument('-r', '--regime', type=str, action='store',
                        choices=["region", "russia"])
    args = parser.parse_args().__dict__
    street = args['street']
    house_number = args['house_number']
    city = args['city']
    regime = args["regime"]
    path = args["path"]
    address = city + ", " + street + ", " + house_number
    if regime == "russia":
        links_to_download = russia
    else:
        links_to_download = region
    if not os.path.isdir(os.path.join(path, 'geodata')):
        Downloader.download_bz2(links_to_download, 'geodata')
    if not os.path.isdir(os.path.join(path, 'prepared')):
        for file in os.listdir(os.path.join(path, 'geodata')):
            if file.endswith(".txt"):
                print(f"preparing file: {os.path.join(path, 'geodata', file)}")
                db = DataBase(os.path.join(path, 'geodata', file),
                              os.path.join(path, 'prepared', file))
                s = Searcher(os.path.join(path, 'prepared', file))
    for file in os.listdir(os.path.join(path, 'prepared')):
        print("Created Searcher")
        s = Searcher(os.path.join(path, 'prepared', file))
        print(DataBase.return_json_address(args['city'], args['street'],
                                           args['house_number'], Searcher.get_median(s.search_nodes(address))))