Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Unittests & a lot of refactoring & pylint findings corrections #16

Merged
merged 26 commits into from
Jul 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ output*/*
tools_dl/
venv/*

# in all folders
**/__pycache__/*

# common resources
common_resources/land-polygons-split-4326/
common_resources/land-polygons-split-4326.zip
common_resources/__pycache__/*
common_resources/*.pyc

# mac/unix
Expand Down
14 changes: 14 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[MESSAGES CONTROL]

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time.
#enable=

# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once).
disable=line-too-long

#import-error, wrong-import-position
8 changes: 8 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
"console": "integratedTerminal",
"args": ["${workspaceRoot}/common_resources/germany-only1.json"]
},
{
"name": "only2-tile",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
"console": "integratedTerminal",
"args": ["${workspaceRoot}/common_resources/germany-only2.json"]
},
{
"name": "only5-tile",
"type": "python",
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,26 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Types of changes

- `Added` for new features.
- `Changed` for changes in existing functionality.
- `Deprecated` for soon-to-be removed features.
- `Removed` for now removed features.
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [Unreleased]
### Added
- unittests for downloader.py methods
### Changed
- pylint findings corrected
- a lot of refactored (focus methods)
- refactor downloader-methods for testing with unittests
- correctly check force_download and force_processing against boolean
- fix pylint findings (focus documentation and imports)
- reduce (double) imported standard modules & delete unused imports
- position of creation of empty directories in `output` folder

## [0.4.0] - 2021-07-01
### Added
Expand Down
3 changes: 3 additions & 0 deletions common_resources/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
constants
"""
#!/usr/bin/python

Translate_Country = {
Expand Down
17 changes: 15 additions & 2 deletions common_resources/constants_functions.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
"""
functions and object for constants
"""
#!/usr/bin/python

# import official python packages
import sys

# import custom python packages
from os import sys, path
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
from common_resources import constants


def get_region_of_country(county):
"""
returns the region / continent of a given country
"""
region = ''
if county in constants.africa :
region = 'africa'
Expand All @@ -31,6 +36,10 @@ def get_region_of_country(county):


def get_geofabrik_region_of_country(input_county):
"""
returns the geofabrik region / continent of a given country
the geofabrik region is sometimes written different than the get_region_of_country() region
"""
# search for country match in geofabrik tables to determine region to use for map download
c_translated = translate_country_input_to_geofabrik(input_county)

Expand Down Expand Up @@ -63,6 +72,10 @@ def get_geofabrik_region_of_country(input_county):


def translate_country_input_to_geofabrik(county):
"""
translates the given country to the geofabrik country
the geofabrik country is sometimes written different
"""
# search for user entered country name in translated (to geofabrik). if match continue with matched else continue with user entered country

try:
Expand Down
Loading