1
0
Fork 0

start using environmental variables and config file

first and main step toward fixing https://codeberg.org/matkoniecz/list_how_openstreetmap_can_be_improved_with_alltheplaces_data/issues/6
This commit is contained in:
Mateusz Konieczny 2024-08-13 14:14:36 +02:00
parent 1c21614911
commit b4ab112f36
5 changed files with 16 additions and 1 deletions

1
.env-template Normal file
View file

@ -0,0 +1 @@
OSM_ATM_MATCHER_CACHE_FOLDER=/media/mateusz/OSM_cache/ATP_matcher_cache

3
.gitignore vendored
View file

@ -8,3 +8,6 @@
nominatim_cache
url_check_cache
distance_distribution_charts
# there will be env file template
.env

View file

@ -1,6 +1,10 @@
import datetime
import osm_bot_abstraction_layer.tag_knowledge as tag_knowledge
import dotenv
import os
dotenv.load_dotenv() # make environment variables specified in .env available
# see https://github.com/theskumar/python-dotenv
def is_nonlocal_phone_worth_mentioning(atp_code):
if datetime.datetime.now() < datetime.datetime(2024, 8, 27):
@ -95,7 +99,7 @@ def consider_reporting_broken_spider(atp_code):
return
def cache_folder():
return "/media/mateusz/OSM_cache/ATP_matcher_cache/"
return os.getenv("OSM_ATM_MATCHER_CACHE_FOLDER") + "/"
def atp_cache_folder():

View file

@ -36,6 +36,12 @@ pip install --requirement requirements-dev.txt # install dependencies
pre-commit install # install pre-commit checks, see https://pre-commit.com/
```
and then customize config files - you need at least to specify where cache will be
```
cp .env-template .env # copy config file template for customization
codium .env # open with whatever text editor you are using, you do not need this specific one
```
## Run tests
Tests are run by pre-commit before each commit.

View file

@ -7,3 +7,4 @@ geopy
diskcache
phonenumbers
plotly
python-dotenv