Your IP : 216.73.216.196


Current Path : /opt/alt/python27/lib/python2.7/site-packages/github/
Upload File :
Current File : //opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyc

�
b�1[c@s9ddlZddd��YZdefd��YZdS(i����NtPaginatedListBasecBsQeZd�Zd�Zd�Zd�Zd�Zd�Zddd��YZRS(	cCst�|_dS(N(tlistt_PaginatedListBase__elements(tself((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyt__init__+scCs\t|ttf�st�t|ttf�rH|j|�|j|S|j||�SdS(N(t
isinstancetinttslicetAssertionErrortlongt _PaginatedListBase__fetchToIndexRt_Slice(Rtindex((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyt__getitem__.s

ccsRx|jD]}|Vq
Wx2|j�rM|j�}x|D]}|Vq;WqWdS(N(Rt
_couldGrowt_grow(RtelementtnewElements((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyt__iter__6s	
cCst|j�|kp|j�S(N(tlenRR(RR((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyt
_isBiggerThan>scCs6x/t|j�|kr1|j�r1|j�qWdS(N(RRRR(RR((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyt__fetchToIndexAs$cCs|j�}|j|7_|S(N(t_fetchNextPageR(RR((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyREsRcBs#eZd�Zd�Zd�ZRS(cCs=||_|jpd|_|j|_|jp3d|_dS(Nii(t_Slice__listtstartt
_Slice__starttstopt_Slice__stoptstept_Slice__step(RttheListttheSlice((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyRKs	ccsU|j}xE|j|�sP|jj|�rI|j|V||j7}qdSqWdS(N(Rt_Slice__finishedRRR(RR((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyRQs	cCs|jdk	o||jkS(N(RtNone(RR((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyt
__finishedZs(t__name__t
__module__RRR (((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyRJs			((	R#R$RR
RRR
RR(((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyR*s						t
PaginatedListcBsqeZdZddd�Zed��Zd�Zed��Zd�Z	d�Z
d�Zd	�Zd
�Z
RS(s�
    This class abstracts the `pagination of the API <http://developer.github.com/v3/#pagination>`_.

    You can simply enumerate through instances of this class::

        for repo in user.get_repos():
            print(repo.name)

    You can also index them or take slices::

        second_repo = user.get_repos()[1]
        first_repos = user.get_repos()[:10]

    If you want to iterate in reversed order, just do::

        for repo in user.get_repos().reversed:
            print(repo.name)

    And if you really need it, you can explicitely access a specific page::

        some_repos = user.get_repos().get_page(0)
        some_other_repos = user.get_repos().get_page(3)
    titemscCs�tj|�||_||_||_|p1d|_||_|pIi|_||_||_	|jj
dkr�|jj
|jd<nt|_d|_dS(Nitper_page((RRt_PaginatedList__requestert_PaginatedList__contentClasst_PaginatedList__firstUrlt_PaginatedList__firstParamst_PaginatedList__nextUrlt_PaginatedList__nextParamst_PaginatedList__headerst_PaginatedList__list_itemR'tFalset	_reversedR!t_PaginatedList__totalCount(RtcontentClasst	requestertfirstUrltfirstParamstheaderst	list_item((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyRws
							cCs|js|j�n|jS(N(R2R(R((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyt
totalCount�s	
cCsR|jjd|jd|jd|j�\}}|j|�}|jd�}|S(NtGETt
parametersR7tlast(R(trequestJsonAndCheckR*R-R.t_PaginatedList__parseLinkHeadertget(RR7tdatatlinkstlastUrl((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyt_getLastPageUrl�s			cCs/t|j|j|j|j�}|j�|S(N(R%R)R(R*R+t_PaginatedList__reverse(Rtr((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pytreversed�s!
cCs+t|_|j�}|r'||_ndS(N(tTrueR1RCR,(RRB((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyt	__reverse�s	cCs
|jdk	S(N(R,R!(R((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyR�scCsH|jjd|jd|jd|j�\}}|r<|ng}d|_t|�dkr�|j|�}|jr�d|kr�|d|_q�q�d|kr�|d|_q�nd|_|j	|kr�|j
d�|_||j	}ng|D]0}|dk	r�|j|j||dt
�^q�}|jrD|ddd	�S|S(
NR:R;R7itprevtnextttotal_countt	completedi����(R(R=R,R-R.R!RR>R1R/R?R2R)R0(RR7R@RARtcontent((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyR�s.						:	cCsvi}d|krr|djd�}xJ|D]?}|jd�\}}|dd!}|dd!}|||<q,Wn|S(Ntlinks, s; ii����i(tsplit(RR7RAtlinkHeaderst
linkHeaderturltrel((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyt__parseLinkHeader�s


cCs�t|j�}|dkr,|d|d<n|jjdkrQ|jj|d<n|jjd|jd|d|j�\}}|j|kr�|jd	�|_	||j}ng|D]$}|j
|j||d
t�^q�S(NiitpageiR'R:R;R7RKRL(tdictR+R(R'R=R*R.R/R?R2R)R0(RRUtparamsR7R@R((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pytget_page�s		N(R#R$t__doc__R!RtpropertyR9RCRFRDRRR>RX(((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyR%^s					((tgithub.GithubObjecttgithubRR%(((sE/opt/alt/python27/lib/python2.7/site-packages/github/PaginatedList.pyt<module>'s4