]> git.openstreetmap.org Git - nominatim.git/blob - nominatim/clicmd/special_phrases.py
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / nominatim / clicmd / special_phrases.py
1 """
2     Implementation of the 'special-phrases' command.
3 """
4 import logging
5 from nominatim.tools.special_phrases import SpecialPhrasesImporter
6 from nominatim.db.connection import connect
7
8 LOG = logging.getLogger()
9
10 # Do not repeat documentation of subcommand classes.
11 # pylint: disable=C0111
12
13 class ImportSpecialPhrases:
14     """\
15     Import special phrases.
16     """
17     @staticmethod
18     def add_args(parser):
19         group = parser.add_argument_group('Input arguments')
20         group.add_argument('--import-from-wiki', action='store_true',
21                            help='Import special phrases from the OSM wiki to the database.')
22
23     @staticmethod
24     def run(args):
25         if args.import_from_wiki:
26             LOG.warning('Special phrases importation starting')
27             with connect(args.config.get_libpq_dsn()) as db_connection:
28                 SpecialPhrasesImporter(
29                     args.config, args.phplib_dir, db_connection
30                 ).import_from_wiki()
31         return 0