]> git.openstreetmap.org Git - nominatim.git/blobdiff - src/nominatim_db/clicmd/export.py
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / src / nominatim_db / clicmd / export.py
index 93f63980b9dec111a99fd4d9c29b65b4642c0dca..c6a100b239fe54881cb25858466d264f0d731e09 100644 (file)
@@ -18,20 +18,15 @@ import nominatim_api as napi
 from nominatim_api.results import create_from_placex_row, ReverseResult, add_result_details
 from nominatim_api.types import LookupDetails
 
-import sqlalchemy as sa # pylint: disable=C0411
+import sqlalchemy as sa
 
 from ..errors import UsageError
 from .args import NominatimArgs
 
-# Do not repeat documentation of subcommand classes.
-# pylint: disable=C0111
-# Using non-top-level imports to avoid eventually unused imports.
-# pylint: disable=E0012,C0415
-# Needed for SQLAlchemy
-# pylint: disable=singleton-comparison
 
 LOG = logging.getLogger()
 
+
 RANK_RANGE_MAP = {
   'country': (4, 4),
   'state': (5, 9),
@@ -42,6 +37,7 @@ RANK_RANGE_MAP = {
   'path': (27, 27)
 }
 
+
 RANK_TO_OUTPUT_MAP = {
     4: 'country',
     5: 'state', 6: 'state', 7: 'state', 8: 'state', 9: 'state',
@@ -50,6 +46,7 @@ RANK_TO_OUTPUT_MAP = {
     17: 'suburb', 18: 'suburb', 19: 'suburb', 20: 'suburb', 21: 'suburb',
     26: 'street', 27: 'path'}
 
+
 class QueryExport:
     """\
     Export places as CSV file from the database.
@@ -84,7 +81,6 @@ class QueryExport:
                            dest='relation',
                            help='Export only children of this OSM relation')
 
-
     def run(self, args: NominatimArgs) -> int:
         return asyncio.run(export(args))
 
@@ -104,15 +100,15 @@ async def export(args: NominatimArgs) -> int:
             t = conn.t.placex
 
             sql = sa.select(t.c.place_id, t.c.parent_place_id,
-                        t.c.osm_type, t.c.osm_id, t.c.name,
-                        t.c.class_, t.c.type, t.c.admin_level,
-                        t.c.address, t.c.extratags,
-                        t.c.housenumber, t.c.postcode, t.c.country_code,
-                        t.c.importance, t.c.wikipedia, t.c.indexed_date,
-                        t.c.rank_address, t.c.rank_search,
-                        t.c.centroid)\
-                     .where(t.c.linked_place_id == None)\
-                     .where(t.c.rank_address.between(*output_range))
+                            t.c.osm_type, t.c.osm_id, t.c.name,
+                            t.c.class_, t.c.type, t.c.admin_level,
+                            t.c.address, t.c.extratags,
+                            t.c.housenumber, t.c.postcode, t.c.country_code,
+                            t.c.importance, t.c.wikipedia, t.c.indexed_date,
+                            t.c.rank_address, t.c.rank_search,
+                            t.c.centroid)\
+                    .where(t.c.linked_place_id == None)\
+                    .where(t.c.rank_address.between(*output_range))
 
             parent_place_id = await get_parent_id(conn, args.node, args.way, args.relation)
             if parent_place_id:
@@ -159,7 +155,6 @@ async def dump_results(conn: napi.SearchConnection,
     await add_result_details(conn, results,
                              LookupDetails(address_details=True, locales=locale))
 
-
     for result in results:
         data = {'placeid': result.place_id,
                 'postcode': result.postcode}