diff --git a/tools/python/__init__.py b/tools/python/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/python/booking/download_hotels.py b/tools/python/booking/download_hotels.py index 01d2ab698e..1374459a61 100755 --- a/tools/python/booking/download_hotels.py +++ b/tools/python/booking/download_hotels.py @@ -14,8 +14,8 @@ import math from eviltransform import gcj2wgs_exact from tqdm import tqdm -from api.booking_api import BookingApi, BookingListApi, LIMIT_REQUESTS_PER_MINUTE -from api.exceptions import GettingMinPriceError +from .api.booking_api import BookingApi, BookingListApi, LIMIT_REQUESTS_PER_MINUTE +from .api.exceptions import GettingMinPriceError SUPPORTED_LANGUAGES = ("en", "ru", "ar", "cs", "da", "nl", "fi", "fr", "de", "hu", "id", "it", "ja", "ko", "pl", "pt", "ro", "es", diff --git a/tools/python/mwm/__init__.py b/tools/python/mwm/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/python/mwm/decode_id.py b/tools/python/mwm/decode_id.py index ba120e9ea2..c362143ab4 100755 --- a/tools/python/mwm/decode_id.py +++ b/tools/python/mwm/decode_id.py @@ -1,7 +1,8 @@ #!/usr/bin/env python -import sys -import mwm import re +import sys + +from . import mwm if len(sys.argv) < 2: print('This script unpacks maps.me OSM id to an OSM object link.') diff --git a/tools/python/mwm/dump_mwm.py b/tools/python/mwm/dump_mwm.py index 98e240eebb..c8ba052085 100755 --- a/tools/python/mwm/dump_mwm.py +++ b/tools/python/mwm/dump_mwm.py @@ -1,7 +1,10 @@ #!/usr/bin/python -import sys, os.path, random import json -from mwm import MWM +import os.path +import random +import sys + +from .mwm import MWM if len(sys.argv) < 2: print('Dumps some MWM structures.') diff --git a/tools/python/mwm/find_feature.py b/tools/python/mwm/find_feature.py index da2f2b4916..bf74b05c4b 100755 --- a/tools/python/mwm/find_feature.py +++ b/tools/python/mwm/find_feature.py @@ -1,6 +1,9 @@ #!/usr/bin/env python -import sys, os.path, json -from mwm import MWM +import json +import os.path +import sys + +from .mwm import MWM if len(sys.argv) < 4: print('Finds features in an mwm file based on a query') diff --git a/tools/python/mwm/ft2osm.py b/tools/python/mwm/ft2osm.py index c2dd1985e1..850f085876 100755 --- a/tools/python/mwm/ft2osm.py +++ b/tools/python/mwm/ft2osm.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import sys -import mwm + +from . import mwm if len(sys.argv) < 3: print('Finds an OSM object for a given feature id.') diff --git a/tools/python/mwm/mwm.py b/tools/python/mwm/mwm.py index 4114f5f77b..3e0f0cb0e0 100644 --- a/tools/python/mwm/mwm.py +++ b/tools/python/mwm/mwm.py @@ -1,8 +1,9 @@ # MWM Reader Module import struct -import math from datetime import datetime +import math + # Unprocessed sections: geomN, trgN, idx, sdx (search index), addr (search address), offs (feature offsets - succinct) # Routing sections: mercedes (matrix), daewoo (edge data), infinity (edge id), skoda (shortcuts), chrysler (cross context), ftseg, node2ftseg # (these mostly are succinct structures, except chrysler and node2ftseg, so no use trying to load them here) diff --git a/tools/python/mwm/mwm_feature_compare.py b/tools/python/mwm/mwm_feature_compare.py index 82787bdadf..5587571fdd 100755 --- a/tools/python/mwm/mwm_feature_compare.py +++ b/tools/python/mwm/mwm_feature_compare.py @@ -1,12 +1,12 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function -from mwm import MWM import argparse -import os import multiprocessing +import os +from .mwm import MWM OMIM_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', '..') diff --git a/tools/python/mwm/requirements.txt b/tools/python/mwm/requirements.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/python/post_generation/__init__.py b/tools/python/post_generation/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/python/hierarchy_to_countries.py b/tools/python/post_generation/hierarchy_to_countries.py similarity index 99% rename from tools/python/hierarchy_to_countries.py rename to tools/python/post_generation/hierarchy_to_countries.py index b16a9918b2..58d97da499 100755 --- a/tools/python/hierarchy_to_countries.py +++ b/tools/python/post_generation/hierarchy_to_countries.py @@ -15,12 +15,15 @@ # 3. Country ISO code (used for flags in the legacy format) # 4. Comma-separated list of language ISO codes for the region # -import sys, json, re -from optparse import OptionParser -import os.path +import base64 import codecs import hashlib -import base64 +import json +import os.path +import re +import sys +from optparse import OptionParser + class CountryDict(dict): def __init__(self, *args, **kwargs): diff --git a/tools/python/local_ads/mwm_to_csv_4localads.py b/tools/python/post_generation/localads_mwm_to_csv.py similarity index 97% rename from tools/python/local_ads/mwm_to_csv_4localads.py rename to tools/python/post_generation/localads_mwm_to_csv.py index 3619f0a48c..4653c2ada3 100755 --- a/tools/python/local_ads/mwm_to_csv_4localads.py +++ b/tools/python/post_generation/localads_mwm_to_csv.py @@ -1,22 +1,14 @@ #!/usr/bin/env python2.7 -import os -import sys - -# TODO: Make mwm an installable module. -sys.path.append( - os.path.join( - os.path.dirname(__file__), '..', 'mwm' - ) -) - import argparse import csv -import mwm -import logging import ctypes -from zlib import adler32 +import logging +import os +import sys from multiprocessing import Pool, Queue, Process +from zlib import adler32 +from ..mwm import mwm HEADERS = { 'mapping': 'osmid fid mwm_id mwm_version source_type'.split(), diff --git a/tools/python/post_generation/requirements.txt b/tools/python/post_generation/requirements.txt new file mode 100644 index 0000000000..b4fb832e2d --- /dev/null +++ b/tools/python/post_generation/requirements.txt @@ -0,0 +1 @@ +-r ../mwm/requirements.txt \ No newline at end of file diff --git a/tools/unix/generate_planet.sh b/tools/unix/generate_planet.sh index 5bfbd77680..0879a816a8 100755 --- a/tools/unix/generate_planet.sh +++ b/tools/unix/generate_planet.sh @@ -225,9 +225,9 @@ else PYTHON_SCRIPTS_PATH="$OMIM_PATH/tools/python" fi ROADS_SCRIPT="$PYTHON_SCRIPTS_PATH/road_runner.py" -HIERARCHY_SCRIPT="$PYTHON_SCRIPTS_PATH/hierarchy_to_countries.py" +HIERARCHY_SCRIPT="$PYTHON_SCRIPTS_PATH/post_generation/hierarchy_to_countries.py" DESCRIPTIONS_DOWNLOADER="$PYTHON_SCRIPTS_PATH/descriptions/descriptions_downloader.py" -LOCALADS_SCRIPT="$PYTHON_SCRIPTS_PATH/local_ads/mwm_to_csv_4localads.py" +LOCALADS_SCRIPT="$PYTHON_SCRIPTS_PATH/post_generation/localads_mwm_to_csv.py" UGC_FILE="${UGC_FILE:-$INTDIR/ugc_db.sqlite3}" POPULAR_PLACES_FILE="${POPULAR_PLACES_FILE:-$INTDIR/popular_places.csv}" WIKIDATA_FILE="${WIKIDATA_FILE:-$INTDIR/idToWikidata.csv}"