Ë
    éxjæU  ã                   ó\  — d Z ddlmZmZmZmZmZmZmZm	Z	 ddl
mZ ddlmZ ddlZddlmZ ddlmZ ddlZddlmZ ddlmZ dd	lmZmZ dd
lmZ ddlmZ ddl Z  e jB                  d«      Z"e"jG                   e jH                  «       «        G d„ de«      Z% G d„ de«      Z& G d„ d«      Z'y)z; Helper functions to communicate with replication servers.
é    )Ú
NamedTupleÚOptionalÚAnyÚIteratorÚcastÚMappingÚTupleÚDictN)ÚURLError)Úcontextmanager)Úceil)ÚHTTPAdapter)ÚRetry)ÚMergeInputReaderÚBaseHandler)Úio)ÚversionÚpyosmiumc                   ó<   — e Zd ZU dZeed<   	 ej                  ed<   y)ÚOsmosisStatez6 Represents a state file of a replication server.
    ÚsequenceÚ	timestampN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚintÚ__annotations__ÚdtÚdatetime© ó    úI/build-osm/venv/lib/python3.12/site-packages/osmium/replication/server.pyr   r      s   … ñàƒMØ5Ø�{‰{ÓØ?r"   r   c                   ó4   — e Zd ZU dZeed<   	 eed<   	 eed<   y)ÚDownloadResultz Downloaded change.
    ÚidÚreaderÚnewestN)r   r   r   r   r   r   r   r!   r"   r#   r%   r%   '   s    … ñàƒGØGØÓØ>ØƒKØ6r"   r%   c                   ó  — e Zd ZdZd*dededdfd„Zd+d„Zd,d„Zd	ed
ededdfd„Z	dededdfd„Z
dedej                  fd„Zdej                  defd„Z	 	 d-dedee   dee   dee   fd„Z	 	 	 d.dededee   dededee   dee   fd„Z	 	 	 	 	 d/dedededee   dedeeeef      dee   dee   deeeef      fd„Z	 	 d0d ej4                  d!ed"edee   fd#„Zd1d$ee   d%edee   fd&„Zd$edefd'„Zd$ee   defd(„Zd$edefd)„Z y)2ÚReplicationServerac   Represents a connection to a  server that publishes replication data.
        Replication change files allow to keep local OSM data up-to-date without
        downloading the full dataset again.

        ReplicationServer may be used as a context manager. In this case, it
        internally keeps a connection to the server making downloads faster.
    ÚurlÚ	diff_typeÚreturnNc                 ó€   — || _         || _        t        dd¬«      | _        d| _        t        dddhg d¢¬	«      | _        y)
a_   Set up the connection to a replication server.

            `url` contains the base URL of the replication service. This is
            the directory that contains the state file with the current
            state. If the replication service serves something other
            than osc.gz files, set the `diff_type` to the given file suffix.
        é<   T)ÚtimeoutÚstreamNé   g      à?ÚGET)i˜  i­  iô  iö  i÷  iø  )ÚtotalÚbackoff_factorÚallowed_methodsÚstatus_forcelist)Úbaseurlr,   ÚdictÚextra_request_paramsÚsessionr   Úretry)Úselfr+   r,   s      r#   Ú__init__zReplicationServer.__init__;   s@   € ð ˆŒØ"ˆŒÜ48ÀÈDÔ4QˆÔ!Ø37ˆŒÜ °3ÈÈÚ,JôLˆ�
r"   c                 ó`   — | j                   �"| j                   j                  «        d| _         yy)z> Close any open connection to the replication server.
        N)r;   Úclose©r=   s    r#   r@   zReplicationServer.closeK   s*   € ð �<‰<Ð#Ø�L‰L×ÑÔ ØˆD�Lð $r"   c                 óø   — t        j                  «       | _        | j                  j                  dt	        | j
                  ¬«      «       | j                  j                  dt	        | j
                  ¬«      «       | S ©Nzhttp://)Úmax_retrieszhttps://)ÚrequestsÚSessionr;   Úmountr   r<   rA   s    r#   Ú	__enter__zReplicationServer.__enter__R   sQ   € Ü×'Ñ'Ó)ˆŒØ�‰×Ñ˜9¤k¸d¿j¹jÔ&IÔJØ�‰×Ñ˜:¤{¸t¿z¹zÔ'JÔKØˆr"   Úexc_typeÚ	exc_valueÚ	tracebackc                 ó$   — | j                  «        y )N)r@   )r=   rI   rJ   rK   s       r#   Ú__exit__zReplicationServer.__exit__X   s   € Ø�
‰
�r"   ÚkeyÚvaluec                 ó"   — || j                   |<   y)a½   Set a parameter which will be handed to the requests library
            when calling `requests.get()`. This
            may be used to set custom headers, timeouts and similar parameters.
            See the `requests documentation <https://requests.readthedocs.io/en/latest/api/?highlight=get#requests.request>`_
            for possible parameters. Per default, a timeout of 60 sec is set
            and streaming download enabled.
        N)r:   )r=   rN   rO   s      r#   Úset_request_parameterz'ReplicationServer.set_request_parameter[   s   € ð */ˆ×!Ñ! #Ò&r"   c                 óZ   — ddt         j                  › �i}t        j                  ||¬«      S )Nz
User-Agentz	pyosmium/)Úheaders)r   Úpyosmium_releaseÚ
urlrequestÚRequest)r=   r+   rS   s      r#   Úmake_requestzReplicationServer.make_requeste   s-   € Ø 9¬W×-EÑ-EÐ,FÐ!GÐHˆÜ×!Ñ! #¨wÔ7Ð7r"   c                 óŽ  ‡ ‡‡— d‰ j                   v r‰ j                   Šn<t        ‰ j                   «      Š‰j                  «       D ��ci c]  \  }}||“Œ
 c}}‰d<   ‰ j                  �+ ‰ j                  j                  ‰j                  «       fi ‰¤ŽS t        dt        t        j                     fˆˆ ˆfd„«       } |«       S c c}}w )zg Download a resource from the given URL and return a byte sequence
            of the content.
        rS   r-   c               3   óB  •K  — t        j                  «       5 } | j                  dt        ‰j                  ¬«      «       | j                  dt        ‰j                  ¬«      «        | j
                  ‰j                  «       fi ‰¤Ž}|–— d d d «       y # 1 sw Y   y xY w­wrC   )rE   rF   rG   r   r<   ÚgetÚget_full_url)r;   ÚrequestÚ
get_paramsr=   r+   s     €€€r#   Ú_get_url_with_sessionz9ReplicationServer.open_url.<locals>._get_url_with_sessionv   sq   øè ø€ ä×!Ñ!Ô# wØ—‘˜i¬ÀÇÁÔ)LÔMØ—‘˜j¬+À$Ç*Á*Ô*MÔNØ%˜'Ÿ+™+ c×&6Ñ&6Ó&8ÑG¸JÑG�Ø’÷	 $×#Ñ#üs   ƒB˜A2BÂ
	BÂBÂB)
r:   r9   Úheader_itemsr;   rZ   r[   r   r   rE   ÚResponse)r=   r+   ÚkÚvr^   r]   s   ``   @r#   Úopen_urlzReplicationServer.open_urli   s¾   ú€ ð ˜×1Ñ1Ñ1Ø×2Ñ2‰Jä˜d×7Ñ7Ó8ˆJØ69×6FÑ6FÔ6HÔ$IÑ6H©d¨a° Q¨¡TÐ6HÒ$IˆJ�yÑ!à�<‰<Ð#Ø#�4—<‘<×#Ñ# C×$4Ñ$4Ó$6ÑE¸*ÑEÐEä	ð	¤x´×0AÑ0AÑ'Bö 	ó 
ð	ñ %Ó&Ð&ùó %Js   ÁCÚstart_idÚmax_sizeÚend_idc                 ó^  — | j                  «       }|�||j                  kD  ry|}d}|�|dz  }n|€d}t        «       }|�|dkD  r´|�||k  r­||j                  k  rž	 | j                  |«      }t        |«      dk(  r||k(  rynw|j                  || j                  «      }
|€t        j                  d|«       n||
z  }t        j                  d||dz  «       |dz  }|�|dkD  r|�||k  r||j                  k  rŒžt        |dz
  ||j                  «      S # t        j
                  $ r‡}	||k(  rJ|	j                  �>|	j                  j                  dz  dk(  r"t        j                  d|	j                  «       |	‚t        j                  d|	«       t        j                  d	«       d
}Y d}	~	�Œ;d}	~	ww xY w)a¥   Create a MergeInputReader and download diffs starting with sequence
            id `start_id` into it. `end_id` optionally gives the highest
            sequence number to download. `max_size` restricts the number of
            diffs that are downloaded by size. If neither `end_id` nor
            `max_size` are given, then download default to stop after 1MB.

            The download stops as soon as
            1. a diff cannot be downloaded or
            2. the end_id (inclusive) is reached or
            3. the unpacked data in memory exceeds `max_size` kB or,
               when no `end_id` and `max_size` are given, 1024kB.

            If some data was downloaded, returns a namedtuple with three fields:
            `id` contains the sequence id of the last downloaded diff, `reader`
            contains the MergeInputReader with the data and `newest` is a
            sequence id of the most recent diff available.

            Returns None if there was no new data was available.

            If there is an error during the download, then the function will
            simply return the already downloaded data. If the reported
            error is a client error (HTTP 4xx) and happens during the download
            of the first diff, then a ::request.HTTPError:: is raised: this
            condition is likely to be permanent and the caller should not
            simply retry without investigating the cause.
        Ni   i   r   éd   é   zPermanent server error: %szError during diff download: %szBailing out.Ú zDownloaded change %d.z:Downloaded change %d. (%d kB available in download buffer)é   )Úget_state_infor   r   Úget_diff_blockrE   ÚRequestExceptionÚresponseÚstatus_codeÚLOGÚerrorÚlenÚ
add_bufferr,   Údebugr%   )r=   rd   re   rf   r(   Ú
current_idÚ	left_sizeÚrdÚdiffdataÚexÚ	diff_sizes              r#   Úcollect_diffszReplicationServer.collect_diffs€   s¶  € ð< ×$Ñ$Ó&ˆàˆ>˜X¨¯©Ò7Øàˆ
Ø#'ˆ	ØÐØ  4™‰IØˆ^Ø#ˆIäÓˆàÐ  I°¢MØ�^ z°VÒ';Ø &§/¡/Ò1ðØ×.Ñ.¨zÓ:�ô �8‹} Ò!Ø˜zÒ)ØØàŸ™ h°·±Ó?ˆIØÐ Ü—	‘	Ð1°:Õ>à˜YÑ&�	Ü—	‘	ÐVØ$ i°$Ñ&6ô8à˜!‰OˆJð? Ð  I°¢MØ�^ z°VÒ';Ø &§/¡/Ó1ô> ˜j¨1™n¨b°&·/±/ÓBÐBøô9 ×,Ñ,ò Ø˜zÒ)ØŸK™KÐ3ØŸ[™[×4Ñ4°sÑ:¸aÒ?ô —I‘IÐ:¸B¿K¹KÔHØ�Hô —	‘	Ð:¸BÔ?Ü—	‘	˜.Ô)Ø–ûðús   ÁD ÄF,Ä%A<F'Æ'F,ÚhandlerÚidxÚsimplifyc                 ó„   — | j                  |||¬«      }|€y|j                  j                  |||¬«       |j                  S )a   Download diffs starting with sequence id `start_id`, merge them
            together and then apply them to handler `handler`. `end_id`
            optionally gives the highest sequence id to download. `max_size`
            allows to restrict the amount of diffs that are downloaded.
            Downloaded diffs are temporarily saved in memory and this parameter
            ensures that pyosmium doesn't run out of memory. `max_size`
            is the maximum size in kB this internal buffer may have.

            If neither `end_id` nor `max_size` are given, the download is
            restricted to a maximum size of 1MB. The download also
            stops when the most recent diff has been processed.

            If `idx` is set, a location cache will be created and applied to
            the way nodes. You should be aware that diff files usually do not
            contain the complete set of nodes when a way is modified. That means
            that you cannot just create a new location cache, apply it to a diff
            and expect to get complete way geometries back. Instead you need to
            do an initial data import using a persistent location cache to
            obtain a full set of node locations and then reuse this location
            cache here when applying diffs.

            Diffs may contain multiple versions of the same object when it was
            changed multiple times during the period covered by the diff. If
            `simplify` is set to False then all versions are returned. If it
            is True (the default) then only the most recent version will be
            sent to the handler.

            The function returns the sequence id of the last diff that was
            downloaded or None if the download failed completely.
        ©rf   re   N)r~   r   )r|   r'   Úapplyr&   )r=   r}   rd   re   r~   r   rf   Údiffss           r#   Úapply_diffszReplicationServer.apply_diffsÏ   sF   € ðD ×"Ñ" 8°FÀXÐ"ÓNˆàˆ=Øà�‰×Ñ˜7¨°hÐÔ?à�x‰xˆr"   ÚinfileÚoutfileÚset_replication_headerÚextra_headersÚ	outformatc	                 óÌ  — | j                  |||¬«      }	|	€yt        j                  «       }
t        j                  ||
¬«      }|j	                  «       j
                  }t        j                  «       }||_        |r‰|j                  d| j                  «       |j                  dt        |	j                  «      «       | j                  |	j                  «      }|�+|j                  d|j                  j                  d«      «       |�*|j                  «       D ]  \  }}|j                  ||«       Œ |€t        j                  |«      }nt        j                  ||«      }||_        t        j                   |||
¬«      }t"        j%                  d«       |	j&                  j)                  |||«       |j+                  «        |j+                  «        |	j                  |	j,                  fS )	a;   Download diffs starting with sequence id `start_id`, merge them
            with the data from the OSM file named `infile` and write the result
            into a file with the name `outfile`. The output file must not yet
            exist.

            `end_id` optionally gives the highest sequence id to download.
            `max_size` allows to restrict the amount of diffs that are
            downloaded. Downloaded diffs are saved in memory and this parameter
            ensures that pyosmium doesn't run out of memory. `max_size`
            is the maximum size in kB this internal buffer may have.

            If neither `end_id` nor `max_size` are given, the
            download is restricted to a maximum size of 1MB. The download also
            stops when the most recent diff has been processed.

            If `set_replication_header` is true then the URL of the replication
            server and the sequence id and timestamp of the last diff applied
            will be written into the `writer`. Note that this currently works
            only for the PBF format.

            `extra_headers` is a dict with additional header fields to be set.
            Most notably, the 'generator' can be set this way.

            `outformat` sets the format of the output file. If None, the format
            is determined from the file name.

            The function returns a tuple of last downloaded sequence id and
            newest available sequence id if new data has been written or None
            if no data was available or the download failed completely.
        r�   N)Úthread_poolÚosmosis_replication_base_urlÚ#osmosis_replication_sequence_numberÚosmosis_replication_timestampz%Y-%m-%dT%H:%M:%SZzMerging changes into OSM file.)r|   ÚoioÚ
ThreadPoolÚReaderÚheaderÚhas_multiple_object_versionsÚHeaderÚsetr8   Ústrr&   rl   r   ÚstrftimeÚitemsÚFileÚWriterrq   ru   r'   Úapply_to_readerr@   r(   )r=   r…   r†   rd   re   r‡   rˆ   r‰   rf   rƒ   r‹   r'   Úhas_historyÚhÚinfora   rb   ÚofÚwriters                      r#   Úapply_diffs_to_filez%ReplicationServer.apply_diffs_to_fileú   s€  € ðH ×"Ñ" 8°FÀXÐ"ÓNˆàˆ=Øä—n‘nÓ&ˆÜ—‘˜F°Ô<ˆØ—m‘m“o×BÑBˆä�J‰J‹LˆØ)4ˆÔ&Ù!Ø�E‰EÐ0°$·,±,Ô?Ø�E‰EÐ7¼¸U¿X¹X»ÔGØ×&Ñ& u§x¡xÓ0ˆDØÐØ—‘Ð5Ø—n‘n×-Ñ-Ð.BÓCôEàÐ$Ø%×+Ñ+Ö-‘��1Ø—‘�a˜•ð .ð ÐÜ—‘˜'Ó"‰Bä—‘˜' 9Ó-ˆBà*5ˆÔ'Ü—‘˜B ¨{Ô;ˆä�	‰	Ð2Ô3à�‰×$Ñ$ V¨V°[ÔAà�‰ŒØ�‰Œà—‘˜%Ÿ,™,Ð'Ð'r"   r   Úbalanced_searchÚlimit_by_oldest_availablec                 ó   — | j                  «       }|€y||j                  k\  s|j                  dk  r|j                  S d}d}|€­t        j	                  d|«       | j                  |«      }|�Q|j                  |k\  rB|j                  dk(  ry|j                  dz   |j                  k\  r|rdS |j                  S |}d}d}|€.t        ||j                  z   dz  «      }||k  r|j                  S |}|€Œ­	 |r&t        |j                  |j                  z   dz  «      }n™|j                  |j                  z
  j                  «       }	|j                  |j                  z
  }
||j                  z
  j                  «       }|j                  t        ||
z  |	z  «      z   }||j                  k\  r|j                  dz
  }| j                  |«      }|€>|dz
  }|€7||j                  kD  r(| j                  |«      }|dz  }|€||j                  kD  rŒ(|€>|dz   }|€7||j                  k  r(| j                  |«      }|dz  }|€||j                  k  rŒ(|€|j                  S |j                  |k  r|}n|}|j                  dz   |j                  k\  r|j                  S �Œž)aí   Get the sequence number of the replication file that contains the
            given timestamp. The search algorithm is optimised for replication
            servers that publish updates in regular intervals. For servers
            with irregular change file publication dates 'balanced_search`
            should be set to true so that a standard binary search for the
            sequence will be used. The default is good for all known
            OSM replication services.

            When `limit_by_oldest_available` is set, then the function will
            return None when the server replication does not start at 0 and
            the given timestamp is older than the oldest available timestamp
            on the server. Some replication servers do not keep the full
            history and this flag avoids accidentally trying to download older
            data. The downside is that the function will never return the
            oldest available sequence ID when the flag is set.
        Nr   zTrying with Id %srk   é   )rl   r   r   rq   ru   r   Útotal_secondsr   )r=   r   r¢   r£   ÚupperÚlowerÚloweridÚnewidÚbase_splitidÚts_intÚseq_intÚgoalÚsplitÚsplitids                 r#   Útimestamp_to_sequencez'ReplicationServer.timestamp_to_sequenceE  s�  € ð( ×#Ñ#Ó%ˆàˆ=ØØ˜Ÿ™Ò'¨5¯>©>¸QÒ+>Ø—>‘>Ð!ð ˆØˆØˆmÜ�I‰IÐ)¨7Ô3Ø×'Ñ'¨Ó0ˆEàÐ  U§_¡_¸	Ò%AØ—>‘> QÒ&ØØ—>‘> AÑ%¨¯©Ò7Ù#<˜4ÐPÀ%Ç.Á.ÐPØ�Ø�Ø�àˆ}ä˜W u§~¡~Ñ5¸Ñ:Ó;�Ø˜GÒ#à Ÿ>™>Ð)Ø�ð' ‰mð2 ÙÜ" E§N¡N°U·^±^Ñ$CÀqÑ#HÓI‘àŸ/™/¨E¯O©OÑ;×JÑJÓL�ØŸ.™.¨5¯>©>Ñ9�Ø! E§O¡OÑ3×BÑBÓD�Ø$Ÿ~™~´°T¸G±^ÀfÑ5LÓ0MÑM�Ø 5§>¡>Ò1Ø#(§>¡>°AÑ#5�LØ×'Ñ'¨Ó5ˆEàˆ}à&¨Ñ*�Ø�m¨°%·.±.Ò(@Ø ×/Ñ/°Ó8�EØ˜q‘L�Gð �m¨°%·.±.Ó(@ð ˆ}à&¨Ñ*�Ø�m¨°%·.±.Ò(@Ø ×/Ñ/°Ó8�EØ˜q‘L�Gð �m¨°%·.±.Ó(@ð ˆ}à—~‘~Ð%ð �‰ Ò*Ø‘à�à�~‰~ Ñ! U§^¡^Ò3Ø—~‘~Ð%ñG r"   ÚseqÚretriesc                 ó¶  — t        |dz   «      D �]o  }d}d}	 | j                  | j                  | j                  |«      «      «      5 }t	        |d«      r!|j                  «        |j                  «       }n|}|D ]æ  }|j                  d«      j                  «       }d|v r|d|j                  d«       }n|j                  «       }|sŒN|j                  dd«      }	t        |	«      dk7  r ddd«        y|	d   d	k(  rt        |	d   «      }Œ�|	d   d
k(  sŒ™	 t        j                  j                  |	d   d«      }|j#                  t        j$                  j&                  ¬«      }Œè ddd«       |€�Œ_|€�Œct3        ||¬«      c S  y# t         $ r Y  Œ-w xY w# 1 sw Y   Œ2xY w# t(        t*        f$ r*}
t,        j/                  dt1        |
«      «       Y d}
~
 yd}
~
ww xY w)af   Downloads and returns the state information for the given
            sequence. If the download is successful, a namedtuple with
            `sequence` and `timestamp` is returned, otherwise the function
            returns `None`. `retries` sets the number of times the download
            is retried when pyosmium detects a truncated state file.
        rk   NÚ
iter_lineszutf-8Ú#r   Ú=r¥   ÚsequenceNumberr   z%Y-%m-%dT%H\:%M\:%SZ)Útzinfoz"Loading state info failed with: %s)r   r   )Úrangerc   rW   Úget_state_urlÚhasattrÚraise_for_statusrµ   ÚdecodeÚstripÚindexr¯   rs   r   r   r    ÚstrptimeÚ
ValueErrorÚreplaceÚtimezoneÚutcr   ÚIOErrorrq   ru   r–   r   )r=   r²   r³   Ú_ÚtsÚnext_seqro   ÚlinesÚlineÚkvÚerrs              r#   rl   z ReplicationServer.get_state_info¡  s·  € ô �w ‘{×#ˆAØˆBØˆHðØ—]‘] 4×#4Ñ#4°T×5GÑ5GÈÓ5LÓ#MÔNÐRZÜ˜x¨Ô6à ×1Ñ1Ô3Ø (× 3Ñ 3Ó 5™à (˜ã %˜Ø#Ÿ{™{¨7Ó3×9Ñ9Ó;˜Ø $™;Ø#'¨¨$¯*©*°S«/Ð#:™Dà#'§:¡:£<˜DÚØ!%§¡¨C°Ó!3˜BÜ" 2›w¨!š|Ø'+÷# OÑNð$  " !™uÐ(8Ò8Ü+.¨r°!©u«:¡Ø!# A¡¨+Ó!5ð!*Ü)+¯©×)=Ñ)=¸bÀ¹eÐE]Ó)^ Bð &(§Z¡Z´r·{±{·± ZÓ%G¡ð# !&÷ Oð> Š~ (Ò"6Ü#¨XÀÔDÒDðK $ðN øô (2ò !*Ú$)ð!*ú÷/ OÐNûô6 œgÐ&ò Ü—	‘	Ð>ÄÀCÃÔIÝûðúsf   ˜/FÁA?FÃ!FÃ(FÃ2FÄ#FÄ6,FÅ"FÆ	F	ÆFÆF	ÆFÆF	ÆFÆGÆ.GÇGc                 óF  — | j                  | j                  | j                  |«      «      «      5 }t        |d«      r3|j	                  «        t        t        |j                  «      cddd«       S t        t        |j                  «       «      cddd«       S # 1 sw Y   yxY w)z½ Downloads the diff with the given sequence number and returns
            it as a byte sequence. Throws an :code:`requests.HTTPError`
            if the file cannot be downloaded.
        ÚcontentN)	rc   rW   Úget_diff_urlr¼   r½   r   r–   rÏ   Úread)r=   r²   Úresps      r#   rm   z ReplicationServer.get_diff_blockÑ  st   € ð
 �]‰]˜4×,Ñ,¨T×->Ñ->¸sÓ-CÓDÔEÈÜ�t˜YÔ'à×%Ñ%Ô'ÜœC §¡Ó.÷	 FÑEô œ˜TŸY™Y›[Ó)÷ F×EÒEús   °6BÁ0BÂB c                 ób   — |€| j                   dz   S d| j                   |dz  |dz  dz  |dz  fz  S )zô Returns the URL of the state.txt files for a given sequence id.

            If seq is `None` the URL for the latest state info is returned,
            i.e. the state file in the root directory of the replication
            service.
        z
/state.txtz%s/%03i/%03i/%03i.state.txté@B éè  )r8   ©r=   r²   s     r#   r»   zReplicationServer.get_state_urlß  sH   € ð ˆ;Ø—<‘< ,Ñ.Ð.à,Ø—‘˜c G™m¨c°G©m¸tÑ-CÀSÈ4ÁZÐPñQð 	Qr"   c                 óV   — d| j                   |dz  |dz  dz  |dz  | j                  fz  S )zE Returns the URL to the diff file for the given sequence id.
        z%s/%03i/%03i/%03i.%srÔ   rÕ   )r8   r,   rÖ   s     r#   rÐ   zReplicationServer.get_diff_urlì  s<   € ð &Ø—‘Ø�g‘  g¡°Ñ5°s¸T±zØ—‘ð ñ ð 	 r"   )zosc.gz)r-   N)r-   r*   )NN)Nrj   TN)NTNNN)FF)Nr¥   )!r   r   r   r   r–   r>   r@   rH   r   rM   rQ   rU   rV   rW   rc   r   r   r%   r|   r   Úboolr„   r   r	   r¡   r   r    r±   r   rl   rm   r»   rÐ   r!   r"   r#   r*   r*   2   so  „ ññL˜Cð L¨Cð L¸tó Ló  óð ð °ð Àð Èó ð/¨ð /°Sð /¸Tó /ð8 ð 8¨
×(:Ñ(:ó 8ð'˜J×.Ñ.ð '°3ó 'ð. FJØ.2ñMC cð MC°X¸c±]ð MCØ& s™mðMCØ7?ÀÑ7OóMCð` /3Ø48Ø,0ñ) ;ð )¸#ð )Ø& s™mð)àð)à-1ð)ð % S™Mð)ð 6>¸c±]ó)ðX 7;Ø;?ØIMØ7;Ø48ñI(¨#ð I(¸ð I(Àsð I(Ø&.¨s¡mðI(à48ðI(ð ,4°G¸CÀ¸HÑ4EÑ+FðI(ð (0°¡}ð	I(ð
 %-¨S¡MðI(ð
 >FÀeÈCÐQTÈHÁoÑ=VóI(ðX 7<Ø@EñZ&¨r¯{©{ð Z&Ø/3ðZ&à9=ðZ&àJRÐSVÉ-óZ&ñx. (¨3¡-ð .Àð .ÈXÐVbÑMcó .ð`* #ð *¨#ó *ðQ ¨#¡ð Q°3ó Qð  ð  ¨ô  r"   r*   )(r   Útypingr   r   r   r   r   r   r	   r
   Úurllib.requestr\   rU   Úurllib.errorr   r    r   Ú
contextlibr   Úmathr   rE   Úrequests.adaptersr   Úurllib3.utilr   Úosmiumr   r   r   r�   r   ÚloggingÚ	getLoggerrq   Ú
addHandlerÚNullHandlerr   r%   r*   r!   r"   r#   Ú<module>rå      s‡   ðñç R× RÓ RÝ #Ý !Û Ý %Ý ã Ý )Ý ç 0Ý Ý ã à€g×Ñ˜
Ó#€Ø ‡�Ð"ˆw×"Ñ"Ó$Ô %ô@�:ô @ô7�Zô 7÷@ ò @ r"   