[generator] Created descriptions module.

This commit is contained in:
Maksim Andrianov 2019-04-19 12:49:30 +03:00 committed by mpimenov
parent 19437eebb5
commit 66b1805bab
5 changed files with 19 additions and 17 deletions

View file

View file

@ -17,6 +17,8 @@ import wikipediaapi
from bs4 import BeautifulSoup
from wikidata.client import Client
from .exceptions import GettingError, ParseError
"""
This script downloads Wikipedia pages for different languages.
"""
@ -35,22 +37,6 @@ BAD_SECTIONS = {
}
class MyException(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class ParseError(MyException):
pass
class GettingError(MyException):
pass
def try_get(obj, prop, *args, **kwargs):
attempts = REQUEST_ATTEMPTS
while attempts != 0:
@ -333,5 +319,6 @@ def main():
else:
log.warning(f"Wikidata ({wikidata_file}) file not set.")
if __name__ == "__main__":
main()

View file

@ -0,0 +1,10 @@
class DescriptionError(Exception):
pass
class ParseError(DescriptionError):
pass
class GettingError(DescriptionError):
pass

View file

@ -0,0 +1,5 @@
htmlmin
requests
bs4
wikidata
wikipedia-api

View file

@ -226,7 +226,7 @@ else
fi
ROADS_SCRIPT="$PYTHON_SCRIPTS_PATH/road_runner.py"
HIERARCHY_SCRIPT="$PYTHON_SCRIPTS_PATH/hierarchy_to_countries.py"
DESCRIPTIONS_DOWNLOADER="$PYTHON_SCRIPTS_PATH/descriptions_downloader.py"
DESCRIPTIONS_DOWNLOADER="$PYTHON_SCRIPTS_PATH/descriptions/descriptions_downloader.py"
LOCALADS_SCRIPT="$PYTHON_SCRIPTS_PATH/local_ads/mwm_to_csv_4localads.py"
UGC_FILE="${UGC_FILE:-$INTDIR/ugc_db.sqlite3}"
POPULAR_PLACES_FILE="${POPULAR_PLACES_FILE:-$INTDIR/popular_places.csv}"