diff --git a/tooling/wahoomc.svg b/tooling/wahoomc.svg new file mode 100644 index 00000000..efb16099 --- /dev/null +++ b/tooling/wahoomc.svg @@ -0,0 +1,305 @@ + + + + + + +G + + + +__main__ + +__main__ + + + +geojson + +geojson + + + +pkg_resources + +pkg_resources + + + +pkg_resources->__main__ + + + + + +requests + +requests + + + +shapely + +shapely + + + +shapely_geometry + +shapely. +geometry + + + +shapely_geometry_Polygon + +shapely. +geometry. +Polygon + + + +wahoomc___main__ + +wahoomc. +__main__ + + + +wahoomc_main + +wahoomc.main + + + +wahoomc___main__->wahoomc_main + + + + + +wahoomc_constants + +wahoomc. +constants + + + +wahoomc_constants_functions + +wahoomc. +constants_functions + + + +wahoomc_constants_functions->wahoomc_constants + + + + + +wahoomc_file_directory_functions + +wahoomc. +file_directory_functions + + + +wahoomc_constants_functions->wahoomc_file_directory_functions + + + + + +wahoomc_downloader + +wahoomc. +downloader + + + +wahoomc_downloader->requests + + + + + +wahoomc_downloader->wahoomc_constants + + + + +wahoomc_downloader->wahoomc_constants_functions + + + + + +wahoomc_geofabrik + +wahoomc. +geofabrik + + + +wahoomc_geofabrik->geojson + + + + + +wahoomc_geofabrik->shapely + + + + + +wahoomc_geofabrik->shapely_geometry + + + + + +wahoomc_geofabrik->shapely_geometry_Polygon + + + + + + +wahoomc_geofabrik->wahoomc_constants + + + + + +wahoomc_init___main__ + +wahoomc. +init. +__main__ + + + +wahoomc_init___main__->wahoomc_main + + + + + +wahoomc_input + +wahoomc.input + + + +wahoomc_input->wahoomc_constants + + + + + + +wahoomc_main->wahoomc_downloader + + + + + +wahoomc_main->wahoomc_input + + + + + +wahoomc_osm_maps_functions + +wahoomc. +osm_maps_functions + + + +wahoomc_main->wahoomc_osm_maps_functions + + + + + +wahoomc_setup_functions + +wahoomc. +setup_functions + + + +wahoomc_main->wahoomc_setup_functions + + + + + +wahoomc_osm_maps_functions->wahoomc_constants + + + + + +wahoomc_osm_maps_functions->wahoomc_constants_functions + + + + + +wahoomc_osm_maps_functions->wahoomc_downloader + + + + + +wahoomc_osm_maps_functions->wahoomc_file_directory_functions + + + + + +wahoomc_osm_maps_functions->wahoomc_geofabrik + + + + + +wahoomc_setup_functions->pkg_resources + + + + + +wahoomc_setup_functions->wahoomc_constants + + + + + + +wahoomc_setup_functions->wahoomc_constants_functions + + + + + + +wahoomc_setup_functions->wahoomc_downloader + + + + + +wahoomc_setup_functions->wahoomc_file_directory_functions + + + + + diff --git a/wahoomc/downloader.py b/wahoomc/downloader.py index 9b8e17a1..c4877864 100644 --- a/wahoomc/downloader.py +++ b/wahoomc/downloader.py @@ -11,10 +11,10 @@ import time import logging import platform +import zipfile import requests # import custom python packages -from wahoomc.file_directory_functions import download_url_to_file, unzip from wahoomc.constants_functions import translate_country_input_to_geofabrik, \ get_geofabrik_region_of_country, get_tooling_win_path @@ -93,6 +93,21 @@ def get_osm_pbf_filepath_url(country): return map_file_path, url +def download_url_to_file(url, map_file_path): + """ + download the content of a ULR to file + """ + # set timeout to 30 minutes (per file) + request_geofabrik = requests.get( + url, allow_redirects=True, stream=True, timeout=1800) + if request_geofabrik.status_code != 200: + log.error('! failed download URL: %s', url) + sys.exit() + + # write content to file + write_to_file(map_file_path, request_geofabrik) + + def download_tooling(): """ Windows @@ -149,6 +164,23 @@ def get_latest_pypi_version(): return None +def write_to_file(file_path, request): + """ + write content of request into given file path + """ + with open(file_path, mode='wb') as file_handle: + for chunk in request.iter_content(chunk_size=1024*100): + file_handle.write(chunk) + + +def unzip(source_filename, dest_dir): + """ + unzip the given file into the given directory + """ + with zipfile.ZipFile(source_filename, 'r') as zip_ref: + zip_ref.extractall(dest_dir) + + class Downloader: """ This is the class to check and download maps / artifacts" diff --git a/wahoomc/file_directory_functions.py b/wahoomc/file_directory_functions.py index d320a6af..76e7e433 100644 --- a/wahoomc/file_directory_functions.py +++ b/wahoomc/file_directory_functions.py @@ -8,24 +8,14 @@ import os from os.path import isfile, join import sys -import zipfile import logging import shutil -import requests # import custom python packages log = logging.getLogger('main-logger') -def unzip(source_filename, dest_dir): - """ - unzip the given file into the given directory - """ - with zipfile.ZipFile(source_filename, 'r') as zip_ref: - zip_ref.extractall(dest_dir) - - def move_content(src_folder_name, dst_path): """ copy files from source directory of to destination directory @@ -116,30 +106,6 @@ def write_json_file_generic(json_file_path, json_content): json_file.close() -def download_url_to_file(url, map_file_path): - """ - download the content of a ULR to file - """ - # set timeout to 30 minutes (per file) - request_geofabrik = requests.get( - url, allow_redirects=True, stream=True, timeout=1800) - if request_geofabrik.status_code != 200: - log.error('! failed download URL: %s', url) - sys.exit() - - # write content to file - write_to_file(map_file_path, request_geofabrik) - - -def write_to_file(file_path, request): - """ - write content of request into given file path - """ - with open(file_path, mode='wb') as file_handle: - for chunk in request.iter_content(chunk_size=1024*100): - file_handle.write(chunk) - - def get_folders_in_folder(folder): """ return foldernames of given folder without path as list