]> git.openstreetmap.org Git - nominatim.git/blobdiff - src/nominatim_db/tools/replication.py
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / src / nominatim_db / tools / replication.py
index 91171deb8cad626a4b64e1ba0bb5a9c95b5aa0ac..082523cd7483d0bcd7a27dc7d99f1f6dccbc7a86 100644 (file)
@@ -33,6 +33,7 @@ except ModuleNotFoundError as exc:
 
 LOG = logging.getLogger()
 
 
 LOG = logging.getLogger()
 
+
 def init_replication(conn: Connection, base_url: str,
                      socket_timeout: int = 60) -> None:
     """ Set up replication for the server at the given base URL.
 def init_replication(conn: Connection, base_url: str,
                      socket_timeout: int = 60) -> None:
     """ Set up replication for the server at the given base URL.
@@ -83,6 +84,7 @@ def check_for_updates(conn: Connection, base_url: str,
     LOG.warning("New data available (%i => %i).", seq, state.sequence)
     return 0
 
     LOG.warning("New data available (%i => %i).", seq, state.sequence)
     return 0
 
+
 class UpdateState(Enum):
     """ Possible states after an update has run.
     """
 class UpdateState(Enum):
     """ Possible states after an update has run.
     """
@@ -125,8 +127,7 @@ def update(dsn: str, options: MutableMapping[str, Any],
     # Read updates into file.
     with _make_replication_server(options['base_url'], socket_timeout) as repl:
         outhandler = WriteHandler(str(options['import_file']))
     # Read updates into file.
     with _make_replication_server(options['base_url'], socket_timeout) as repl:
         outhandler = WriteHandler(str(options['import_file']))
-        # tyoing: work around typing bug in pyosmium 4.0
-        endseq = repl.apply_diffs(outhandler, startseq + 1, # type: ignore[arg-type]
+        endseq = repl.apply_diffs(outhandler, startseq + 1,
                                   max_size=options['max_diff_size'] * 1024)
         outhandler.close()
 
                                   max_size=options['max_diff_size'] * 1024)
         outhandler.close()
 
@@ -177,12 +178,12 @@ def _make_replication_server(url: str, timeout: int) -> ContextManager[Replicati
             """ Download a resource from the given URL and return a byte sequence
                 of the content.
             """
             """ Download a resource from the given URL and return a byte sequence
                 of the content.
             """
-            headers = {"User-Agent" : f"Nominatim (pyosmium/{pyo_version.pyosmium_release})"}
+            headers = {"User-Agent": f"Nominatim (pyosmium/{pyo_version.pyosmium_release})"}
 
             if self.session is not None:
                 return self.session.get(url.get_full_url(),
 
             if self.session is not None:
                 return self.session.get(url.get_full_url(),
-                                       headers=headers, timeout=timeout or None,
-                                       stream=True)
+                                        headers=headers, timeout=timeout or None,
+                                        stream=True)
 
             @contextmanager
             def _get_url_with_session() -> Iterator[requests.Response]:
 
             @contextmanager
             def _get_url_with_session() -> Iterator[requests.Response]: