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

[DEV] Change structure of repository to python module #115

Merged
merged 7 commits into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- [Git Guidelines](#git-guidelines)
- [No Merge Commits](#no-merge-commits)
- [Pull Requests](#pull-requests)
- [Pull Request Title](#pull-request-title)
- [Squash Commit Summary](#squash-commit-summary)
- [Release](#release)
- [Automatic CHANGELOG creation](#automatic-changelog-creation)
- [Structure of the repository](#structure-of-the-repository)
Expand Down Expand Up @@ -79,7 +81,7 @@ The folders in the repo have the following purposes:
- common_python - custom python files
- common_resources - config, json files
- tooling - programs, scripts used by Windows and macOS
- tooling_windows - programs, scripts for Windows
- tooling_win - programs, scripts for Windows

## Anaconda environment
- /conda_env/gdal-user.yml is for creating Anaconda environment for users
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ jobs:
pip install pylint
- name: Analysing the code with pylint
run: |
pylint -j 0 . ./common_python ./tests --fail-under=9.87
pylint -j 0 ./wahoo_mc ./tests --fail-under=9.87
continue-on-error: false
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ osmconvert_tempfile.*
# mac/unix

#windows
/tooling_windows/osmconvert_tempfile.*
/wahoo_mc/tooling_win/osmconvert_tempfile.*
26 changes: 13 additions & 13 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "x/y: 134/88 (STG)",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
"module": "wahoo_mc",
"console": "integratedTerminal",
"args": [
"cli",
Expand All @@ -22,7 +22,7 @@
"name": "x/y: 134/88,134/87 (STG+HN)",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
"module": "wahoo_mc",
"console": "integratedTerminal",
"args": [
"cli",
Expand All @@ -39,7 +39,7 @@
"name": "germany",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
"module": "wahoo_mc",
"console": "integratedTerminal",
"args": [
"cli",
Expand All @@ -51,7 +51,7 @@
"name": "malta",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
"module": "wahoo_mc",
"console": "integratedTerminal",
"args": [
"cli",
Expand All @@ -69,7 +69,7 @@
"name": "malta-geofabrik",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
"module": "wahoo_mc",
"console": "integratedTerminal",
"args": [
"cli",
Expand All @@ -88,7 +88,7 @@
"name": "gui",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
"module": "wahoo_mc",
"console": "integratedTerminal",
"args": [
"gui"
Expand All @@ -98,7 +98,7 @@
"name": "cli help",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
"module": "wahoo_mc",
"console": "integratedTerminal",
"args": [
"-h"
Expand All @@ -108,7 +108,7 @@
"name": "test_2_malta",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
"module": "wahoo_mc",
"console": "integratedTerminal",
"args": [
"cli",
Expand All @@ -126,7 +126,7 @@
"name": "test_2_liech",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
"module": "wahoo_mc",
"console": "integratedTerminal",
"args": [
"cli",
Expand All @@ -145,7 +145,7 @@
"name": "x/y: 133/88 (germany&france)",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
"module": "wahoo_mc",
"console": "integratedTerminal",
"args": [
"cli",
Expand All @@ -157,7 +157,7 @@
"name": "x/y: 138/100 (malta)",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
"module": "wahoo_mc",
"console": "integratedTerminal",
"args": [
"cli",
Expand All @@ -169,7 +169,7 @@
"name": "x/y: 138/100,133/88 (two tiles)",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
"module": "wahoo_mc",
"console": "integratedTerminal",
"args": [
"cli",
Expand All @@ -181,7 +181,7 @@
"name": "x/y: stg->gardasee (ten tiles)",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
"module": "wahoo_mc",
"console": "integratedTerminal",
"args": [
"cli",
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ conda activate gdal-user
```
Run wahooMapsCreator via GUI
```
python wahoo_map_creator.py gui
python -m wahoo_mc gui
```
Or run wahooMapsCreator via CLI
```
python wahoo_map_creator.py cli -co malta
python -m wahoo_mc cli -co malta
```

A detailled description of the usage is documented [:computer: here](docs/USAGE.md#usage-of-wahoomapscreator)
Expand Down
Empty file removed common_python/__init__.py
Empty file.
20 changes: 10 additions & 10 deletions copyFilesToDist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ cd ../..
cd dist/${FOLDER_NAME_MAC}

# create empty sub-folders
mkdir -p ./common_python
mkdir -p ./common_resources
mkdir -p ./wahoo_mc
mkdir -p ./wahoo_mc/resources
mkdir -p ./conda_env
mkdir -p ./tooling
mkdir -p ./docs

# copy files into dist-folder
cp -a ../../common_python/*.py ./common_python/
cp -a ../../common_resources/*.xml ./common_resources/
cp -a ../../common_resources/*.osm ../../common_resources/*.py ./common_resources/
cp -a ../../common_resources/json/ ./common_resources/json
cp -a ../../common_resources/tag_wahoo_adjusted/ ./common_resources/tag_wahoo_adjusted
cp -a ../../common_resources/tag_wahoo_initial/ ./common_resources/tag_wahoo_initial
cp -a ../../wahoo_mc/*.py ./wahoo_mc/
cp -a ../../wahoo_mc/resources/*.xml ./wahoo_mc/resources/
cp -a ../../wahoo_mc/resources/*.osm ../../wahoo_mc/resources/*.py ./wahoo_mc/resources/
cp -a ../../wahoo_mc/resources/json/ ./wahoo_mc/resources/json
cp -a ../../wahoo_mc/resources/tag_wahoo_adjusted/ ./wahoo_mc/resources/tag_wahoo_adjusted
cp -a ../../wahoo_mc/resources/tag_wahoo_initial/ ./wahoo_mc/resources/tag_wahoo_initial

cp -a ../../docs/*.md ./docs/
cp -a ../../wahoo_map_creator.py ../../CHANGELOG.md ../../README.md ./
cp -a ../../CHANGELOG.md ../../README.md ./

# file for virtual environments / legacy pip install
cp -a ../../conda_env/gdal-user.yml ./conda_env/
Expand All @@ -46,7 +46,7 @@ cd ..
cp -R ${FOLDER_NAME_MAC}/* ${FOLDER_NAME_WIN}

# add Win specific stuff
cp -a ../tooling_windows ./${FOLDER_NAME_WIN}/tooling_windows
cp -a ../tooling_win ./${FOLDER_NAME_WIN}/tooling_win

# zip content into .zip file - by cd'ing without including root folder
cd ${FOLDER_NAME_MAC}
Expand Down
22 changes: 11 additions & 11 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ In a next step you can run it for your own country.
## GUI (Graphical User Interface)

From the `root` folder of wahooMapsCreator, run:
- `python wahoo_map_creator.py gui`
- `python -m wahoo_mc gui`

Set your arguments as required via the window:

Expand All @@ -21,34 +21,34 @@ Set your arguments as required via the window:
## CLI (Command Line Interface)

From the `root` folder of wahooMapsCreator, run:
- `python wahoo_map_creator.py cli -co <country_name>`
- `python -m wahoo_mc cli -co <country_name>`

Examples:
- for Malta: `python wahoo_map_creator.py cli -co malta`
- for Ireland: `python wahoo_map_creator.py cli -co ireland`
- for Malta: `python -m wahoo_mc cli -co malta`
- for Ireland: `python -m wahoo_mc cli -co ireland`

## Advanced CLI-Usage
The script supports many arguments via command line.
For a list of all supported arguments, run:
- `python wahoo_map_creator.py cli -h`
- `python -m wahoo_mc cli -h`

### Main arguments
**Create maps for a country**
- `python wahoo_map_creator.py cli -co <country>`
- `python -m wahoo_mc cli -co <country>`

**Create maps for X/Y coordinates**

In particular for testing adjustments in configuration-files or coding it is helpful to create maps for only one tile or a handful of tiles!

To create maps for only one tile and not a whole country, one can use the X/Y coordinates of that tile. X/Y coordinates can be retrieved from this in zoom-level 8: [link](http://tools.geofabrik.de/map/#8/50.3079/8.8026&type=Geofabrik_Standard&grid=1).
- `python wahoo_map_creator.py cli -xy <xy_coordinate,xy_coordinate>`
- `python -m wahoo_mc cli -xy <xy_coordinate,xy_coordinate>`

### Examples
- for Malta, download new maps if existing maps are older than 100 days and process files even if files exist
- `python wahoo_map_creator.py cli -co malta -md 100 -fp`
- `python -m wahoo_mc cli -co malta -md 100 -fp`
- for Germany, download and process whole tiles which involves other countries than the given
- `python wahoo_map_creator.py cli -co germany -bc`
- `python -m wahoo_mc cli -co germany -bc`
- to create maps for only one tile
- `python wahoo_map_creator.py cli -xy 134/88`
- `python -m wahoo_mc cli -xy 134/88`
- for multiple tiles
- `python wahoo_map_creator.py cli -xy 134/88,133/88`
- `python -m wahoo_mc cli -xy 134/88,133/88`
6 changes: 3 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_top_parser_help(self):
tests, if help of top parser can be called
"""

result = os.system("python wahoo_map_creator.py -h")
result = os.system("python -h wahoo_mc -h")

self.assertEqual(result, 0)

Expand All @@ -26,7 +26,7 @@ def test_cli_help(self):
tests, if CLI help can be called
"""

result = os.system("python wahoo_map_creator.py cli -h")
result = os.system("python -h wahoo_mc cli -h")

self.assertEqual(result, 0)

Expand All @@ -35,7 +35,7 @@ def test_gui_help(self):
tests, if GUI help can be called
"""

result = os.system("python wahoo_map_creator.py gui -h")
result = os.system("python -h wahoo_mc gui -h")

self.assertEqual(result, 0)

Expand Down
22 changes: 11 additions & 11 deletions tests/test_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from mock import patch


from common_python.constants_functions import translate_country_input_to_geofabrik
from common_python.constants_functions import translate_tags_to_keep
import common_python.constants as const
from wahoo_mc.constants_functions import translate_country_input_to_geofabrik
from wahoo_mc.constants_functions import translate_tags_to_keep
import wahoo_mc.constants as const


class TestTranslateCountries(unittest.TestCase):
Expand Down Expand Up @@ -86,7 +86,7 @@ class TestTranslateTags(unittest.TestCase):
tests for translating tags-constants between the universal format and OS-specific formats
"""

@patch('common_python.constants.TAGS_TO_KEEP_UNIVERSAL', tags_universal_simple)
@patch('wahoo_mc.constants.TAGS_TO_KEEP_UNIVERSAL', tags_universal_simple)
def test_translate_tags_to_keep_simple_macos(self):
"""
Test translating tags to keep from universal format to macOS
Expand All @@ -97,7 +97,7 @@ def test_translate_tags_to_keep_simple_macos(self):
transl_tags = translate_tags_to_keep()
self.assertEqual(tags, transl_tags)

@patch('common_python.constants.TAGS_TO_KEEP_UNIVERSAL', tags_universal_simple)
@patch('wahoo_mc.constants.TAGS_TO_KEEP_UNIVERSAL', tags_universal_simple)
def test_translate_tags_to_keep_simple_win(self):
"""
Test translating tags to keep from universal format to Windows
Expand All @@ -108,7 +108,7 @@ def test_translate_tags_to_keep_simple_win(self):
transl_tags = translate_tags_to_keep(sys_platform='Windows')
self.assertEqual(tags_win, transl_tags)

@patch('common_python.constants.TAGS_TO_KEEP_UNIVERSAL', tags_universal_adv)
@patch('wahoo_mc.constants.TAGS_TO_KEEP_UNIVERSAL', tags_universal_adv)
def test_translate_tags_to_keep_adv_macos(self):
"""
Test translating tags to keep from universal format to macOS
Expand All @@ -120,7 +120,7 @@ def test_translate_tags_to_keep_adv_macos(self):
transl_tags = translate_tags_to_keep()
self.assertEqual(tags, transl_tags)

@patch('common_python.constants.TAGS_TO_KEEP_UNIVERSAL', tags_universal_adv)
@patch('wahoo_mc.constants.TAGS_TO_KEEP_UNIVERSAL', tags_universal_adv)
def test_translate_tags_to_keep_adv_win(self):
"""
Test translating tags to keep from universal format to Windows
Expand All @@ -131,7 +131,7 @@ def test_translate_tags_to_keep_adv_win(self):
transl_tags = translate_tags_to_keep(sys_platform='Windows')
self.assertEqual(tags_win, transl_tags)

# @patch('common_python.constants.TAGS_TO_KEEP_UNIVERSAL', tags_universal_full)
# @patch('wahoo_mc.constants.TAGS_TO_KEEP_UNIVERSAL', tags_universal_full)
def test_translate_tags_to_keep_full_macos(self):
"""
Test translating tags to keep from universal format to macOS // all "tags to keep"
Expand All @@ -146,7 +146,7 @@ def test_translate_tags_to_keep_full_macos(self):
transl_tags = translate_tags_to_keep()
self.assertEqual(tags, transl_tags)

# @patch('common_python.constants.TAGS_TO_KEEP_UNIVERSAL', tags_universal_full)
# @patch('wahoo_mc.constants.TAGS_TO_KEEP_UNIVERSAL', tags_universal_full)
def test_translate_tags_to_keep_full_win(self):
"""
Test translating tags to keep from universal format to Windows // all "tags to keep"
Expand All @@ -157,7 +157,7 @@ def test_translate_tags_to_keep_full_win(self):
transl_tags = translate_tags_to_keep(sys_platform='Windows')
self.assertEqual(tags_win, transl_tags)

# @patch('common_python.constants.NAME_TAGS_TO_KEEP_UNIVERSAL', name_tags_universal_full)
# @patch('wahoo_mc.constants.NAME_TAGS_TO_KEEP_UNIVERSAL', name_tags_universal_full)
def test_translate_name_tags_to_keep_full_macos(self):
"""
Test translating name tags to keep from universal format to Windows // all "name tags to keep"
Expand All @@ -169,7 +169,7 @@ def test_translate_name_tags_to_keep_full_macos(self):
transl_tags = translate_tags_to_keep(name_tags=True)
self.assertEqual(names_tags, transl_tags)

# @patch('common_python.constants.NAME_TAGS_TO_KEEP_UNIVERSAL', name_tags_universal_full)
# @patch('wahoo_mc.constants.NAME_TAGS_TO_KEEP_UNIVERSAL', name_tags_universal_full)
def test_translate_name_tags_to_keep_full_win(self):
"""
Test translating name tags to keep from universal format to macOS // all "name tags to keep"
Expand Down
10 changes: 5 additions & 5 deletions tests/test_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
# import custom python packages
# sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from common_python.downloader import older_than_x_days
from common_python.downloader import download_file
from common_python.downloader import get_osm_pbf_filepath_url
from common_python.downloader import Downloader
from common_python import file_directory_functions as fd_fct
from wahoo_mc.downloader import older_than_x_days
from wahoo_mc.downloader import download_file
from wahoo_mc.downloader import get_osm_pbf_filepath_url
from wahoo_mc.downloader import Downloader
from wahoo_mc import file_directory_functions as fd_fct


class TestDownloader(unittest.TestCase):
Expand Down
Loading