
    x
h_                    *   d dl mZ d dlZd dlmZmZmZ d dlmZ d dlm	Z	 d dl
mZmZmZ d dlmZmZ d dlmZ d	d
ddddddZd dZ G d deej                  Z G d de          Z G d de          Z G d de          Z G d de          ZdS )!    )annotationsN)datetime	timedeltatimezone)Any)
deprecated)IdleModePriorityRatioLimitMode)	ContainerFile)format_timedeltastoppedcheck pendingcheckingdownload pendingdownloadingseed pendingseeding)r                     codeintreturnstrc                @    t                               |           pd|  S )z-Get the torrent status using new status codeszunknown status )_STATUS_NEW_MAPPINGget)r   s    Q/var/www/html/mejor/venv/lib/python3.11/site-packages/transmission_rpc/torrent.py
get_statusr$      s$    ""4((D,Dd,D,DD    c                      e Zd ZdZdZ	 dZ	 dZ	 dZ	 dZ	 dZ		 dZ
	 edd            Zedd            Zedd            Zedd            Zedd            Zedd            Zedd            ZddZdS )Statuszenum for torrent statusr   r   r   r   r   r   r   r   boolc                    | dk    S )zif torrent stoppedr    selfs    r#   r   zStatus.stopped3        y  r%   c                    | dk    S )zif torrent check pendingr   r*   r+   s    r#   check_pendingzStatus.check_pending8   s     &&r%   c                    | dk    S )zif torrent checkingr   r*   r+   s    r#   r   zStatus.checking=   s     z!!r%   c                    | dk    S )zif download pendingr   r*   r+   s    r#   download_pendingzStatus.download_pendingB   s     )))r%   c                    | dk    S )zif downloadingr   r*   r+   s    r#   r   zStatus.downloadingG   s     }$$r%   c                    | dk    S )zif seed pendingr   r*   r+   s    r#   seed_pendingzStatus.seed_pendingL   s     ~%%r%   c                    | dk    S )z
if seedingr   r*   r+   s    r#   r   zStatus.seedingQ   r-   r%   r   c                    | j         S )N)valuer+   s    r#   __str__zStatus.__str__V   s
    zr%   Nr   r(   r   r   )__name__
__module____qualname____doc__STOPPEDCHECK_PENDINGCHECKINGDOWNLOAD_PENDINGDOWNLOADINGSEED_PENDINGSEEDINGpropertyr   r/   r   r2   r   r5   r   r9   r*   r%   r#   r'   r'      sE       !!G
#M
H
)
K
!L
G
! ! ! X! ' ' ' X' " " " X" * * * X* % % % X% & & & X& ! ! ! X!     r%   r'   c                  Z    e Zd ZdZedd            Zedd            Zedd            ZdS )	FileStatz0
    type for :py:meth:`Torrent.file_stats`
    r   r   c                    | j         d         S )NbytesCompletedfieldsr+   s    r#   rK   zFileStat.bytesCompleted_       {+,,r%   c                    | j         d         S )NwantedrL   r+   s    r#   rP   zFileStat.wantedc       {8$$r%   c                    | j         d         S )NpriorityrL   r+   s    r#   rS   zFileStat.priorityg       {:&&r%   Nr   r   )r<   r=   r>   r?   rG   rK   rP   rS   r*   r%   r#   rI   rI   Z   s~          - - - X- % % % X% ' ' ' X' ' 'r%   rI   c                  r    e Zd ZdZed
d            Zedd            Zedd            Zed
d            Zd	S )Trackerz.
    type for :py:attr:`Torrent.trackers`
    r   r   c                    | j         d         S NidrL   r+   s    r#   rZ   z
Tracker.idq       {4  r%   r   c                    | j         d         S NannouncerL   r+   s    r#   r^   zTracker.announceu   rT   r%   c                    | j         d         S NscraperL   r+   s    r#   ra   zTracker.scrapey   rQ   r%   c                    | j         d         S NtierrL   r+   s    r#   rd   zTracker.tier}       {6""r%   NrU   r;   )	r<   r=   r>   r?   rG   rZ   r^   ra   rd   r*   r%   r#   rW   rW   l   s          ! ! ! X! ' ' ' X' % % % X% # # # X# # #r%   rW   c                     e Zd ZdZed"d            Zed"d            Zed#d            Zed"d            Zed$d
            Z	ed$d            Z
ed#d            Zed$d            Zed"d            Zed#d            Zed"d            Zed$d            Zed"d            Zed$d            Zed#d            Zed"d            Zed$d            Zed"d            Zed$d            Zed"d            Zed"d            Zed"d            Zed"d            Zed#d            Zed"d            Zed#d            Zed"d             Zd!S )%TrackerStatsz3
    type for :py:attr:`Torrent.tracker_stats`
    r   r   c                    | j         d         S rY   rL   r+   s    r#   rZ   zTrackerStats.id   r[   r%   c                    | j         d         S )NannounceStaterL   r+   s    r#   announce_statezTrackerStats.announce_state       {?++r%   r   c                    | j         d         S r]   rL   r+   s    r#   r^   zTrackerStats.announce   rT   r%   c                    | j         d         S )NdownloadCountrL   r+   s    r#   download_countzTrackerStats.download_count   rl   r%   r(   c                    | j         d         S )NhasAnnouncedrL   r+   s    r#   has_announcedzTrackerStats.has_announced       {>**r%   c                    | j         d         S )N
hasScrapedrL   r+   s    r#   has_scrapedzTrackerStats.has_scraped       {<((r%   c                    | j         d         S )NhostrL   r+   s    r#   rz   zTrackerStats.host   re   r%   c                    | j         d         S )NisBackuprL   r+   s    r#   	is_backupzTrackerStats.is_backup   rT   r%   c                    | j         d         S )NlastAnnouncePeerCountrL   r+   s    r#   last_announce_peer_countz%TrackerStats.last_announce_peer_count       {233r%   c                    | j         d         S )NlastAnnounceResultrL   r+   s    r#   last_announce_resultz!TrackerStats.last_announce_result       {/00r%   c                    | j         d         S )NlastAnnounceStartTimerL   r+   s    r#   last_announce_start_timez%TrackerStats.last_announce_start_time   r   r%   c                    | j         d         S )NlastAnnounceSucceededrL   r+   s    r#   last_announce_succeededz$TrackerStats.last_announce_succeeded   r   r%   c                    | j         d         S )NlastAnnounceTimerL   r+   s    r#   last_announce_timezTrackerStats.last_announce_time       {-..r%   c                    | j         d         S )NlastAnnounceTimedOutrL   r+   s    r#   last_announce_timed_outz$TrackerStats.last_announce_timed_out   s    {122r%   c                    | j         d         S )NlastScrapeResultrL   r+   s    r#   last_scrape_resultzTrackerStats.last_scrape_result   r   r%   c                    | j         d         S )NlastScrapeStartTimerL   r+   s    r#   last_scrape_start_timez#TrackerStats.last_scrape_start_time       {011r%   c                    | j         d         S )NlastScrapeSucceededrL   r+   s    r#   last_scrape_succeededz"TrackerStats.last_scrape_succeeded   r   r%   c                    | j         d         S )NlastScrapeTimerL   r+   s    r#   last_scrape_timezTrackerStats.last_scrape_time   rN   r%   c                    | j         d         S )NlastScrapeTimedOutrL   r+   s    r#   last_scrape_timed_outz"TrackerStats.last_scrape_timed_out   r   r%   c                    | j         d         S )NleecherCountrL   r+   s    r#   leecher_countzTrackerStats.leecher_count   rt   r%   c                    | j         d         S )NnextAnnounceTimerL   r+   s    r#   next_announce_timezTrackerStats.next_announce_time   r   r%   c                    | j         d         S )NnextScrapeTimerL   r+   s    r#   next_scrape_timezTrackerStats.next_scrape_time   rN   r%   c                    | j         d         S )NscrapeStaterL   r+   s    r#   scrape_statezTrackerStats.scrape_state       {=))r%   c                    | j         d         S r`   rL   r+   s    r#   ra   zTrackerStats.scrape   rQ   r%   c                    | j         d         S )NseederCountrL   r+   s    r#   seeder_countzTrackerStats.seeder_count   r   r%   c                    | j         d         S )NsitenamerL   r+   s    r#   	site_namezTrackerStats.site_name   rT   r%   c                    | j         d         S rc   rL   r+   s    r#   rd   zTrackerStats.tier   re   r%   NrU   r;   r:   ) r<   r=   r>   r?   rG   rZ   rk   r^   rp   rs   rw   rz   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ra   r   r   rd   r*   r%   r#   rg   rg      s~         ! ! ! X! , , , X, ' ' ' X' , , , X, + + + X+ ) ) ) X) # # # X# ' ' ' X' 4 4 4 X4 1 1 1 X1 4 4 4 X4 4 4 4 X4 / / / X/ 3 3 3 X3 / / / X/ 2 2 2 X2 2 2 2 X2 - - - X- 1 1 1 X1 + + + X+ / / / X/ - - - X- * * * X* % % % X% * * * X* ' ' ' X' # # # X# # #r%   rg   c                      e Zd ZdZdu fdZedvd            Zedwd	            Zedwd
            Zedwd            Z	edwd            Z
e ed          dwd                        Zedxd            Zedyd            Zedwd            Zedvd            Zedwd            Zedvd            Zedwd            Zedvd            Zedvd            Zedzd            Zed{d            Zedvd            Zedwd            Zed|d!            Zed|d"            Zed}d$            Zd~d&Zedd(            Zedwd)            Zedvd*            Z edvd+            Z!edzd,            Z"edzd-            Z#edzd.            Z$edzd/            Z%edd1            Z&edvd2            Z'edwd3            Z(ed{d4            Z)edvd5            Z*edxd6            Z+edvd7            Z,edvd8            Z-edvd9            Z.edvd:            Z/edvd;            Z0edvd<            Z1edxd=            Z2edxd>            Z3edwd?            Z4edvd@            Z5edvdA            Z6edwdB            Z7edvdC            Z8edvdD            Z9edvdE            Z:edxdF            Z;edvdG            Z<edvdH            Z=edvdI            Z>edvdJ            Z?eddL            Z@eddM            ZAeddO            ZBedvdP            ZCedwdQ            ZDedvdR            ZEedvdS            ZFedzdT            ZGedxdU            ZHeddW            ZIeddX            ZJedvdY            ZKedvdZ            ZLedwd[            ZMedd]            ZNedzd^            ZOedzd_            ZPedzd`            ZQedzda            ZRedzdb            ZSedzdc            ZTedzdd            ZUedxde            ZVedxdf            ZWed{dg            ZXed{dh            ZYed{di            ZZeddk            Z[dwdlZ\edydm            Z]eddo            Z^edxdp            Z_eddr            Z`dwdsZadwdtZb xZcS )Torrentz
    Torrent is a class holding the data received from Transmission regarding a bittorrent transfer.

    Warnings:
        setter on Torrent's properties has been removed, please use :py:meth:`Client.change_torrent` instead
    rM   dict[str, Any]c               r    d|vrt          d          t                                          |           d S )NrZ   zgTorrent object requires field 'id', you need to add 'id' in your 'arguments' when calling 'get_torrent'rL   )
ValueErrorsuper__init__)r,   rM   	__class__s     r#   r   zTorrent.__init__   sI    vV  
 	'''''r%   r   r   c                    | j         d         S rY   rL   r+   s    r#   rZ   z
Torrent.id  r[   r%   r   c                    | j         d         S )NnamerL   r+   s    r#   r   zTorrent.name	  re   r%   c                    | j         d         S z8Torrent info hash string, can also be used as Torrent ID
hashStringrL   r+   s    r#   r   zTorrent.hashString       {<((r%   c                    | j         d         S r   rL   r+   s    r#   hash_stringzTorrent.hash_string  r   r%   c                    | j         S zalias of ``hashString``r   r+   s    r#   	info_hashzTorrent.info_hash  s     r%   z9this is a typo, do not use this. use `.info_hash` insteadc                    | j         S r   r   r+   s    r#   	into_hashzTorrent.into_hash  s     r%   floatc                    | j         }t          d | j        d         D                       }| j        |z   }t	          |r||z  dz  nd          S )zAvailability in percentc              3  &   K   | ]}|d          V  dS )rK   Nr*   .0xs     r#   	<genexpr>z$Torrent.available.<locals>.<genexpr>&  s(      OO+,OOOOOOr%   	fileStatsd   r   )
total_sizesumrM   desired_availabler   )r,   	bytes_all
bytes_donebytes_avails       r#   	availablezTorrent.available"  s]     O	OOdk+6NOOOOO
,z9	HkI-44qIIIr%   r
   c                6    t          | j        d                   S )z!this torrent's bandwidth prioritybandwidthPriorityr
   rM   r+   s    r#   bandwidth_priorityzTorrent.bandwidth_priority/  s     $78999r%   c                    | j         d         S )NcommentrL   r+   s    r#   r   zTorrent.comment4      {9%%r%   c                    | j         d         S )z
        Byte count of all the corrupt data you've ever downloaded for
        this torrent. If you're on a poisoned torrent, this number can
        grow very large.
        corruptEverrL   r+   s    r#   corrupt_everzTorrent.corrupt_ever8       {=))r%   c                    | j         d         S )NcreatorrL   r+   s    r#   r   zTorrent.creatorA  r   r%   c                    | j         d         S )z
        Byte count of all the piece data we want and don't have yet,
        but that a connected peer does have. [0...leftUntilDone]
        desiredAvailablerL   r+   s    r#   r   zTorrent.desired_availableJ  s     {-..r%   c                    | j         d         S )zrThe download directory.

        :available: transmission version 1.5.
        :available: RPC version 4.
        downloadDirrL   r+   s    r#   download_dirzTorrent.download_dirR  r   r%   c                    | j         d         S )z
        Byte count of all the non-corrupt data you've ever downloaded for this torrent.
        If you deleted the files and downloaded a second time, this will be 2*totalSize.
        downloadedEverrL   r+   s    r#   downloaded_everzTorrent.downloaded_ever[  s     {+,,r%   c                    | j         d         S )NdownloadLimitrL   r+   s    r#   download_limitzTorrent.download_limitc  rl   r%   r(   c                    | j         d         S )NdownloadLimitedrL   r+   s    r#   download_limitedzTorrent.download_limitedg  s    {,--r%   r   c                V    t          j        | j        d         t          j                  S )a  
        The last time during this session that a rarely-changing field
        changed -- e.g. any tr_torrent_metainfo field (trackers, filenames, name)
        or download directory. RPC clients can monitor this to know when
        to reload fields that rarely change.
        editDater   fromtimestamprM   r   utcr+   s    r#   	edit_datezTorrent.edit_datek  s      %dk*&=x|LLLr%   c                    | j         d         S )z/``0`` for fine task, non-zero for error torrenterrorrL   r+   s    r#   r  zTorrent.erroru  s     {7##r%   c                    | j         d         S )zempty string for fine taskerrorStringrL   r+   s    r#   error_stringzTorrent.error_stringz  s     {=))r%   timedelta | Nonec                L    | j         d         }|dk    rt          |          S dS )a  
        the "eta" as datetime.timedelta.

        If downloading, estimated the ``timedelta`` left until the torrent is done.
        If seeding, estimated the ``timedelta`` left until seed ratio is reached.

        raw `eta` maybe negative:
        - `-1` for ETA Not Available.
        - `-2` for ETA Unknown.

        https://github.com/transmission/transmission/blob/3.00/libtransmission/transmission.h#L1748-L1749
        etar   secondsNrM   r   r,   r  s     r#   r  zTorrent.eta  s/     k% !88S))))tr%   c                L    | j         d         }|dk    rt          |          S d S )NetaIdler   r  r
  )r,   vs     r#   eta_idlezTorrent.eta_idle  s-    K	"66Q''''tr%   
int | Nonec                    | j         d         S )Nz
file-countrL   r+   s    r#   
file_countzTorrent.file_count  rx   r%   
list[File]c           	         g }d| j         v rr| j         d         }t          t          |                    }| j         d         }| j         d         }|                    d t	          ||||          D                        |S )a  
        Get list of files for this torrent.

        Note:
            The order of the files is guaranteed. The index of file object is the id of the file
            when calling :py:meth:`transmission_rpc.Client.change_torrent`

        .. code-block:: python

            from transmission_rpc import Client

            torrent = Client().get_torrent(0)

            for file in torrent.get_files():
                print(file.id)

        files
prioritiesrP   c           	   3     K   | ]J\  }}}}t          t          |          t          |          |d          |d         |d         |          V  KdS )lengthr   rK   )selectedrS   sizer   	completedrZ   N)r   r(   r
   )r   rZ   fileraw_priorityraw_selecteds        r#   r   z$Torrent.get_files.<locals>.<genexpr>  s       
 
 9BlL !,//%l33hf"#34  
 
 
 
 
 
r%   )rM   rangelenextendzip)r,   resultr  indicesr  rP   s         r#   	get_fileszTorrent.get_files  s    $  dk!!K(ECJJ''G\2J[*FMM 
 
 =@PZ\b<c<c
 
 
 
 
 
 r%   list[FileStat]c                0    d | j         d         D             S )z
file statsc                .    g | ]}t          |           S rL   )rI   r   s     r#   
<listcomp>z&Torrent.file_stats.<locals>.<listcomp>  s#    EEEq"""EEEr%   r   rL   r+   s    r#   
file_statszTorrent.file_stats  s      FEDK,DEEEEr%   c                .    |                      dd          S )Ngroup )r"   r+   s    r#   r-  zTorrent.group  s    xx$$$r%   c                    | j         d         S )z
        Byte count of all the partial piece data we have for this torrent.
        As pieces become complete,
        this value may decrease as portions of it are moved to "corrupt" or "haveValid".
        haveUncheckedrL   r+   s    r#   have_uncheckedzTorrent.have_unchecked  s     {?++r%   c                    | j         d         S )zFByte count of all the checksum-verified data we have for this torrent.	haveValidrL   r+   s    r#   
have_validzTorrent.have_valid  s     {;''r%   c                    | j         d         S )z)true if session upload limits are honoredhonorsSessionLimitsrL   r+   s    r#   honors_session_limitszTorrent.honors_session_limits       {011r%   c                    | j         d         S )N
isFinishedrL   r+   s    r#   is_finishedzTorrent.is_finished  rx   r%   c                    | j         d         S )N	isPrivaterL   r+   s    r#   
is_privatezTorrent.is_private      {;''r%   c                    | j         d         S )N	isStalledrL   r+   s    r#   
is_stalledzTorrent.is_stalled  r?  r%   	list[str]c                    | j         d         S )NlabelsrL   r+   s    r#   rE  zTorrent.labels  rQ   r%   c                    | j         d         S )z
        Byte count of how much data is left to be downloaded until we've got
        all the pieces that we want. [0...tr_stat.sizeWhenDone]
        leftUntilDonerL   r+   s    r#   left_until_donezTorrent.left_until_done  s     {?++r%   c                    | j         d         S )N
magnetLinkrL   r+   s    r#   magnet_linkzTorrent.magnet_link  rx   r%   c                V    t          j        | j        d         t          j                  S )NmanualAnnounceTimer   r+   s    r#   manual_announce_timezTorrent.manual_announce_time  s    %dk2F&GVVVr%   c                    | j         d         S )NmaxConnectedPeersrL   r+   s    r#   max_connected_peerszTorrent.max_connected_peers       {.//r%   c                6    t          | j        d                   S )z
        How much of the metadata the torrent has.
        For torrents added from a torrent this will always be 1.
        For magnet links, this number will from from 0 to 1 as the metadata is downloaded.
        Range is [0..1]
        metadataPercentCompleter   rM   r+   s    r#   metadata_percent_completez!Torrent.metadata_percent_complete  s     T[!:;<<<r%   c                    | j         d         S )zmaximum number of peersz
peer-limitrL   r+   s    r#   
peer_limitzTorrent.peer_limit  r   r%   c                    | j         d         S )NpeersrL   r+   s    r#   rZ  zTorrent.peers  s    {7##r%   c                    | j         d         S )z'Number of peers that we're connected topeersConnectedrL   r+   s    r#   peers_connectedzTorrent.peers_connected  s     {+,,r%   c                    | j         d         S )zHow many peers we found out about from the tracker, or from pex,
        or from incoming connections, or from our resume file.	peersFromrL   r+   s    r#   
peers_fromzTorrent.peers_from  s     {;''r%   c                    | j         d         S )z*Number of peers that we're sending data topeersGettingFromUsrL   r+   s    r#   peers_getting_from_uszTorrent.peers_getting_from_us"  s     {/00r%   c                    | j         d         S )z,Number of peers that are sending data to us.peersSendingToUsrL   r+   s    r#   peers_sending_to_uszTorrent.peers_sending_to_us'  s     {-..r%   c                6    t          | j        d                   S )zCHow much has been downloaded of the entire torrent. Range is [0..1]percentCompleterU  r+   s    r#   percent_completezTorrent.percent_complete,  s     T[!23444r%   c                6    t          | j        d                   S )z
        How much has been downloaded of the files the user wants. This differs
        from percentComplete if the user wants only some of the torrent's files.
        Range is [0..1]
        percentDonerU  r+   s    r#   percent_donezTorrent.percent_done1  s     T[/000r%   c                    | j         d         S )z
        A bitfield holding pieceCount flags which are set to 'true'
        if we have the piece matching that position.

        JSON doesn't allow raw binary data, so this is a base64-encoded string. (Source: tr_torrent)
        piecesrL   r+   s    r#   rn  zTorrent.pieces:  s     {8$$r%   c                    | j         d         S )N
pieceCountrL   r+   s    r#   piece_countzTorrent.piece_countD  rx   r%   c                    | j         d         S )N	pieceSizerL   r+   s    r#   
piece_sizezTorrent.piece_sizeH  r?  r%   c                    | j         d         S )Nzprimary-mime-typerL   r+   s    r#   primary_mime_typezTorrent.primary_mime_typeQ  rR  r%   c                    | j         d         S )z-position of this torrent in its queue [0...n)queuePositionrL   r+   s    r#   queue_positionzTorrent.queue_positionU  s     {?++r%   c                    | j         d         S )zdownload rate (B/s)rateDownloadrL   r+   s    r#   rate_downloadzTorrent.rate_downloadZ  s     {>**r%   c                    | j         d         S )zupload rate (B/s)
rateUploadrL   r+   s    r#   rate_uploadzTorrent.rate_upload_  r   r%   c                6    t          | j        d                   S )NrecheckProgressrU  r+   s    r#   recheck_progresszTorrent.recheck_progressd  s    T[!23444r%   c                    | j         d         S )NsecondsDownloadingrL   r+   s    r#   seconds_downloadingzTorrent.seconds_downloadingh  r   r%   c                    | j         d         S )NsecondsSeedingrL   r+   s    r#   seconds_seedingzTorrent.seconds_seedingl  rN   r%   c                    | j         d         S )NseedIdleLimitrL   r+   s    r#   seed_idle_limitzTorrent.seed_idle_limitp  rl   r%   c                    | j         d         S )NsizeWhenDonerL   r+   s    r#   size_when_donezTorrent.size_when_doney  rt   r%   list[Tracker]c                0    d | j         d         D             S )ztrackers of torrentc                .    g | ]}t          |           S r)  )rW   r   s     r#   r*  z$Torrent.trackers.<locals>.<listcomp>  s#    CCCaq!!!CCCr%   trackersrL   r+   s    r#   r  zTorrent.trackers}  s      DC4;z+BCCCCr%   c                T    d | j         d                                         D             S )zlist of str of announce URLsc                    g | ]}||S r*   r*   r   s     r#   r*  z(Torrent.tracker_list.<locals>.<listcomp>  s    HHHaaHHHHr%   trackerList)rM   
splitlinesr+   s    r#   tracker_listzTorrent.tracker_list  s,     IH4;}5@@BBHHHHr%   list[TrackerStats]c                0    d | j         d         D             S )z<tracker status, for example, announce success/failure statusc                .    g | ]}t          |           S r)  )rg   r   s     r#   r*  z)Torrent.tracker_stats.<locals>.<listcomp>  s#    LLL1A&&&LLLr%   trackerStatsrL   r+   s    r#   tracker_statszTorrent.tracker_stats  s      MLN0KLLLLr%   c                    | j         d         S )N	totalSizerL   r+   s    r#   r   zTorrent.total_size  r?  r%   c                    | j         d         S )z
        torrent file location on transmission server

        Examples
        --------
        /var/lib/transmission-daemon/.config/transmission-daemon/torrents/00000000000000000000000000.torrent
        torrentFilerL   r+   s    r#   torrent_filezTorrent.torrent_file  s     {=))r%   c                    | j         d         S )NuploadedEverrL   r+   s    r#   uploaded_everzTorrent.uploaded_ever  rt   r%   c                    | j         d         S )NuploadLimitrL   r+   s    r#   upload_limitzTorrent.upload_limit  r   r%   c                    | j         d         S )NuploadLimitedrL   r+   s    r#   upload_limitedzTorrent.upload_limited  rl   r%   c                6    t          | j        d                   S )NuploadRatiorU  r+   s    r#   upload_ratiozTorrent.upload_ratio  s    T[/000r%   	list[int]c                    | j         d         S )zFif files are wanted, sorted by file index. 1 for wanted 0 for unwantedrP   rL   r+   s    r#   rP   zTorrent.wanted       {8$$r%   c                    | j         d         S )NwebseedsrL   r+   s    r#   r  zTorrent.webseeds  rT   r%   c                    | j         d         S )z/Number of webseeds that are sending data to us.webseedsSendingToUsrL   r+   s    r#   webseeds_sending_to_uszTorrent.webseeds_sending_to_us  r8  r%   c                    | j         d         S zGet the torrent statusstatusrL   r+   s    r#   _statuszTorrent._status  r  r%   c                6    t          | j        d                   S r  )r$   rM   r+   s    r#   _status_strzTorrent._status_str  s     $+h/000r%   r'   c                *    t          | j                  S )a  
        Returns the torrent status. Is either one of 'check pending', 'checking',
        'downloading', 'download pending', 'seeding', 'seed pending' or 'stopped'.
        The first two is related to verification.

        Examples:

        .. code-block:: python

            torrent = Torrent()
            torrent.status.downloading
            torrent.status == 'downloading'

        )r'   r  r+   s    r#   r  zTorrent.status  s      d&'''r%   c                    | j         dk    S )Nr   r  r+   s    r#   r   zTorrent.stopped      |q  r%   c                    | j         dk    S )Nr   r  r+   s    r#   r/   zTorrent.check_pending  r  r%   c                    | j         dk    S )Nr   r  r+   s    r#   r   zTorrent.checking  r  r%   c                    | j         dk    S )Nr   r  r+   s    r#   r2   zTorrent.download_pending  r  r%   c                    | j         dk    S )Nr   r  r+   s    r#   r   zTorrent.downloading  r  r%   c                    | j         dk    S )Nr   r  r+   s    r#   r5   zTorrent.seed_pending  r  r%   c                    | j         dk    S )Nr   r  r+   s    r#   r   zTorrent.seeding  r  r%   c                   	 t          d| j        d         z  d          S # t          $ rV 	 | j        d         }| j        d         }t          d||z
  z  t          |          z  d          cY S # t          $ r Y Y dS w xY ww xY w)z/
        download progress in percent.
        g      Y@rk  r   r  rG  g        )roundrM   KeyErrorr   ZeroDivisionError)r,   r  lefts      r#   progresszTorrent.progress  s    
		%$+m"<<qAAA 	 	 	{>2{?3etd{3eDkkAAFFFFF$   sss	s,     
B ?A-*B -
A<7B ;A<<B c                6    t          | j        d                   S )z(
        upload/download ratio.
        r  rU  r+   s    r#   ratiozTorrent.ratio  s    
 T[/000r%   c                V    t          j        | j        d         t          j                  S )aW  
        The last time we uploaded or downloaded piece data on this torrent.
        the attribute ``activityDate`` as ``datetime.datetime`` in **UTC timezone**.

        .. note::

            raw ``activityDate`` value could be ``0`` for never activated torrent,
            therefore it can't always be converted to local timezone.
        activityDater   r+   s    r#   activity_datezTorrent.activity_date  s      %dk.&A8<PPPr%   c                V    t          j        | j        d         t          j                  S )z!When the torrent was first added.	addedDater   r+   s    r#   
added_datezTorrent.added_date        %dk+&>MMMr%   c                V    t          j        | j        d         t          j                  S )zEraw field ``startDate`` as ``datetime.datetime`` in **utc timezone**.	startDater   r+   s    r#   
start_datezTorrent.start_date  r  r%   datetime | Nonec                x    | j         d         }|dk    rdS t          j        |                                          S )zUthe attribute "doneDate" as datetime.datetime. returns None if "doneDate" is invalid.doneDater   N)rM   r   r   
astimezone)r,   	done_dates     r#   r  zTorrent.done_date   s=     K
+	 >>4%i00;;===r%   c                v    | j         d         }|dk    rdS |dk    rdS t          t          |                    S )z
        Returns the attribute *eta* formatted as a string.

        * If eta is -1 the result is 'not available'
        * If eta is -2 the result is 'unknown'
        * Otherwise eta is formatted as <days> <hours>:<minutes>:<seconds>.
        r  znot availableunknownr  )rM   r   r   r  s     r#   
format_etazTorrent.format_eta*  sE     k% "99"?"999	# 6 6 6777r%   c                6    t          | j        d                   S )zq
        Bandwidth priority as string.
        Can be one of 'low', 'normal', 'high'. This is a mutator.
        r   r   r+   s    r#   rS   zTorrent.priorityC  s     $78999r%   r	   c                6    t          | j        d                   S )z
        Seed idle mode as string. Can be one of 'global', 'single' or 'unlimited'.

         * global, use session seed idle limit.
         * single, use torrent seed idle limit. See seed_idle_limit.
         * unlimited, no seed idle limit.
        seedIdleMode)r	   rM   r+   s    r#   seed_idle_modezTorrent.seed_idle_modeL  s     N3444r%   c                6    t          | j        d                   S )zi
        Torrent seed ratio limit as float. Also see seed_ratio_mode.
        This is a mutator.
        seedRatioLimitrU  r+   s    r#   seed_ratio_limitzTorrent.seed_ratio_limitW  s     T[!12333r%   r   c                6    t          | j        d                   S )a  
        Seed ratio mode as string. Can be one of 'global', 'single' or 'unlimited'.

         * global, use session seed ratio limit.
         * single, use torrent seed ratio limit. See seed_ratio_limit.
         * unlimited, no seed ratio limit.
        seedRatioMode)r   rM   r+   s    r#   seed_ratio_modezTorrent.seed_ratio_mode`  s     dk/:;;;r%   c                    d| j         dS )Nz%<transmission_rpc.Torrent hashString=>r   r+   s    r#   __repr__zTorrent.__repr__k  s    KtKKKKr%   c                    d| j         dS )Nz<transmission_rpc.Torrent r  )r   r+   s    r#   r9   zTorrent.__str__n  s    :DI::::r%   )rM   r   rU   r;   )r   r   )r   r
   r:   )r   r   )r   r  )r   r  )r   r  )r   r&  )r   rC  )r   r  )r   r  )r   r  )r   r'   )r   r  )r   r	   )r   r   )dr<   r=   r>   r?   r   rG   rZ   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r%  r+  r-  r1  r4  r7  r;  r>  rB  rE  rH  rK  rN  rQ  rV  rX  rZ  r]  r`  rc  rf  ri  rl  rn  rq  rt  rv  ry  r|  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  rP   r  r  r  r  r  r   r/   r   r2   r   r5   r   r  r  r  r  r  r  r  rS   r  r  r  r  r9   __classcell__)r   s   @r#   r   r      s        ( ( ( ( ( ( ! ! ! X! # # # X# ) ) ) X) ) ) ) X)    X ZKLL   ML X J J J XJ : : : X: & & & X& * * * X* & & & X& / / / X/ * * * X* - - - X- , , , X, . . . X. M M M XM $ $ $ X$ * * * X*    X&    X ) ) ) X)$ $ $ $L F F F XF % % % X% , , , X, ( ( ( X( 2 2 2 X2 ) ) ) X) ( ( ( X( ( ( ( X( % % % X% , , , X, ) ) ) X) W W W XW 0 0 0 X0 = = = X= ) ) ) X) $ $ $ X$ - - - X- ( ( ( X(
 1 1 1 X1 / / / X/ 5 5 5 X5 1 1 1 X1 % % % X% ) ) ) X) ( ( ( X( 0 0 0 X0 , , , X, + + + X+ ) ) ) X) 5 5 5 X5 1 1 1 X1 - - - X- , , , X, + + + X+ D D D XD I I I XI M M M XM ( ( ( X( * * * X* + + + X+ * * * X* , , , X, 1 1 1 X1 % % % X% ' ' ' X' 2 2 2 X2 % % % X% 1 1 1 X1 ( ( ( X(" ! ! ! X! ! ! ! X! ! ! ! X! ! ! ! X! ! ! ! X! ! ! ! X! ! ! ! X!    X 1 1 1 X1 Q Q Q XQ N N N XN N N N XN > > > X>8 8 8 82 : : : X: 5 5 5 X5 4 4 4 X4 < < < X<L L L L; ; ; ; ; ; ; ;r%   r   )r   r   r   r   )
__future__r   enumr   r   r   typingr   typing_extensionsr   transmission_rpc.constantsr	   r
   r   transmission_rpc.typesr   r   transmission_rpc.utilsr   r!   r$   r   Enumr'   rI   rW   rg   r   r*   r%   r#   <module>r     s   " " " " " "  2 2 2 2 2 2 2 2 2 2       ( ( ( ( ( ( I I I I I I I I I I 2 2 2 2 2 2 2 2 3 3 3 3 3 3   E E E E
: : : : :S$) : : :z' ' ' ' 'y ' ' '$# # # # #i # # #,o# o# o# o# o#9 o# o# o#d{	; {	; {	; {	; {	;i {	; {	; {	; {	; {	;r%   