|
28 | 28 | LOG.addHandler(logging.NullHandler()) |
29 | 29 |
|
30 | 30 | class OsmosisState(NamedTuple): |
| 31 | + """ Represents a state file of a replication server. |
| 32 | + """ |
31 | 33 | sequence: int |
| 34 | + "The ID of the replication change on the server." |
32 | 35 | timestamp: dt.datetime |
| 36 | + "Date until when changes are contained in the change file." |
33 | 37 |
|
34 | 38 | class DownloadResult(NamedTuple): |
| 39 | + """ Downloaded change. |
| 40 | + """ |
35 | 41 | id: int |
| 42 | + "The ID of the latest downloaded replication change on the server." |
36 | 43 | reader: MergeInputReader |
| 44 | + "[osmium.MergeInputReader][] with all downloaded changes." |
37 | 45 | newest: int |
| 46 | + "ID of the newest change available on the server." |
38 | 47 |
|
39 | 48 | class ReplicationServer: |
40 | 49 | """ Represents a connection to a server that publishes replication data. |
41 | 50 | Replication change files allow to keep local OSM data up-to-date without |
42 | 51 | downloading the full dataset again. |
43 | 52 |
|
44 | | - `url` contains the base URL of the replication service. This is the |
45 | | - directory that contains the state file with the current state. If the |
46 | | - replication service serves something other than osc.gz files, set |
47 | | - the `diff_type` to the given file suffix. |
48 | | -
|
49 | 53 | ReplicationServer may be used as a context manager. In this case, it |
50 | 54 | internally keeps a connection to the server making downloads faster. |
51 | 55 | """ |
52 | 56 |
|
53 | 57 | def __init__(self, url: str, diff_type: str = 'osc.gz') -> None: |
| 58 | + """ Set up the connection to a replication server. |
| 59 | +
|
| 60 | + `url` contains the base URL of the replication service. This is |
| 61 | + the directory that contains the state file with the current |
| 62 | + state. If the replication service serves something other |
| 63 | + than osc.gz files, set the `diff_type` to the given file suffix. |
| 64 | + """ |
| 65 | + |
54 | 66 | self.baseurl = url |
55 | 67 | self.diff_type = diff_type |
56 | 68 | self.extra_request_params: dict[str, Any] = dict(timeout=60, stream=True) |
|
0 commit comments