mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 18:37:58 +00:00
reorganize api submodule
Use a directory for the submodule where the __init__ file contains the public API. This makes it easier to separate public interface from the internal implementation.
This commit is contained in:
19
nominatim/api/__init__.py
Normal file
19
nominatim/api/__init__.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
The public interface of the Nominatim library.
|
||||
|
||||
Classes and functions defined in this file are considered stable. Always
|
||||
import from this file, not from the source files directly.
|
||||
"""
|
||||
|
||||
# See also https://github.com/PyCQA/pylint/issues/6006
|
||||
# pylint: disable=useless-import-alias
|
||||
|
||||
from nominatim.api.core import (NominatimAPI as NominatimAPI,
|
||||
NominatimAPIAsync as NominatimAPIAsync)
|
||||
from nominatim.api.status import (StatusResult as StatusResult)
|
||||
@@ -17,7 +17,7 @@ import sqlalchemy.ext.asyncio as sa_asyncio
|
||||
import asyncpg
|
||||
|
||||
from nominatim.config import Configuration
|
||||
from nominatim.apicmd.status import get_status, StatusResult
|
||||
from nominatim.api.status import get_status, StatusResult
|
||||
|
||||
class NominatimAPIAsync:
|
||||
""" API loader asynchornous version.
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2022 by the Nominatim developer community.
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Subcommand definitions for API calls from the command line.
|
||||
@@ -14,8 +14,7 @@ import logging
|
||||
from nominatim.tools.exec_utils import run_api_script
|
||||
from nominatim.errors import UsageError
|
||||
from nominatim.clicmd.args import NominatimArgs
|
||||
from nominatim.api import NominatimAPI
|
||||
from nominatim.apicmd.status import StatusResult
|
||||
from nominatim.api import NominatimAPI, StatusResult
|
||||
import nominatim.result_formatter.v1 as formatting
|
||||
|
||||
# Do not repeat documentation of subcommand classes.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2022 by the Nominatim developer community.
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Output formatters for API version v1.
|
||||
@@ -12,7 +12,7 @@ from collections import OrderedDict
|
||||
import json
|
||||
|
||||
from nominatim.result_formatter.base import FormatDispatcher
|
||||
from nominatim.apicmd.status import StatusResult
|
||||
from nominatim.api import StatusResult
|
||||
|
||||
create = FormatDispatcher()
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2022 by the Nominatim developer community.
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Server implementation using the falcon webserver framework.
|
||||
@@ -13,8 +13,7 @@ from pathlib import Path
|
||||
import falcon
|
||||
import falcon.asgi
|
||||
|
||||
from nominatim.api import NominatimAPIAsync
|
||||
from nominatim.apicmd.status import StatusResult
|
||||
from nominatim.api import NominatimAPIAsync, StatusResult
|
||||
import nominatim.result_formatter.v1 as formatting
|
||||
|
||||
CONTENT_TYPE = {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2022 by the Nominatim developer community.
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Server implementation using the sanic webserver framework.
|
||||
@@ -12,8 +12,7 @@ from pathlib import Path
|
||||
|
||||
import sanic
|
||||
|
||||
from nominatim.api import NominatimAPIAsync
|
||||
from nominatim.apicmd.status import StatusResult
|
||||
from nominatim.api import NominatimAPIAsync, StatusResult
|
||||
import nominatim.result_formatter.v1 as formatting
|
||||
|
||||
api = sanic.Blueprint('NominatimAPI')
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2022 by the Nominatim developer community.
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Server implementation using the starlette webserver framework.
|
||||
@@ -16,8 +16,7 @@ from starlette.exceptions import HTTPException
|
||||
from starlette.responses import Response
|
||||
from starlette.requests import Request
|
||||
|
||||
from nominatim.api import NominatimAPIAsync
|
||||
from nominatim.apicmd.status import StatusResult
|
||||
from nominatim.api import NominatimAPIAsync, StatusResult
|
||||
import nominatim.result_formatter.v1 as formatting
|
||||
|
||||
CONTENT_TYPE = {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2022 by the Nominatim developer community.
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Tests for API access commands of command-line interface wrapper.
|
||||
@@ -11,8 +11,7 @@ import json
|
||||
import pytest
|
||||
|
||||
import nominatim.clicmd.api
|
||||
import nominatim.api
|
||||
from nominatim.apicmd.status import StatusResult
|
||||
import nominatim.api as napi
|
||||
|
||||
|
||||
@pytest.mark.parametrize("endpoint", (('search', 'reverse', 'lookup', 'details', 'status')))
|
||||
@@ -61,8 +60,8 @@ class TestCliStatusCall:
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_status_mock(self, monkeypatch):
|
||||
monkeypatch.setattr(nominatim.api.NominatimAPI, 'status',
|
||||
lambda self: StatusResult(200, 'OK'))
|
||||
monkeypatch.setattr(napi.NominatimAPI, 'status',
|
||||
lambda self: napi.StatusResult(200, 'OK'))
|
||||
|
||||
|
||||
def test_status_simple(self, cli_call, tmp_path):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2022 by the Nominatim developer community.
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Tests for formatting results for the V1 API.
|
||||
@@ -11,7 +11,7 @@ import datetime as dt
|
||||
import pytest
|
||||
|
||||
import nominatim.result_formatter.v1 as format_module
|
||||
from nominatim.apicmd.status import StatusResult
|
||||
from nominatim.api import StatusResult
|
||||
from nominatim.version import NOMINATIM_VERSION
|
||||
|
||||
STATUS_FORMATS = {'text', 'json'}
|
||||
|
||||
Reference in New Issue
Block a user