-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/
File Upload :
Current File : //usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pyc


:Nc@@sdZddlmZyddlZWn;ek
rcyddlZWqdek
r_dZqdXnXddlZddlZddl	Z	ddl
mZmZde
fdYZdZdZd	Zd
ZdZdS(s6Tools for dealing with the Launchpad API without using launchpadlib.

The api itself is a RESTful interface, so we can make HTTP queries directly.
loading launchpadlib itself has a fairly high overhead (just calling
Launchpad.login_anonymously() takes a 500ms once the WADL is cached, and 5+s to
get the WADL.
i(tabsolute_importN(trevisionttracetLatestPublicationcB@sneZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
RS(sCEncapsulate how to find the latest publication for a given project.shttps://api.launchpad.net/1.0cC@s#||_||_|j|dS(N(t_archivet_projectt_setup_series_and_pocket(tselftarchivetseriestproject((sH/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pyt__init__5s		cC@ss||_d|_|jdk	rfd|jkrf|jjdd\|_|_|jj|_n	d|_dS(sParse the 'series' info into a series and a pocket.

        eg::
            _setup_series_and_pocket('natty-proposed')
            => _series == 'natty'
               _pocket == 'Proposed'
        t-itReleaseN(t_seriestNonet_pockettsplitttitle(RR	((sH/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pyR:s		!cC@sd|j|jfS(sReturn the Launchpad 'Archive' URL that we will query.
        This is everything in the URL except the query parameters.
        s%s/%s/+archive/primary(tLP_API_ROOTR(R((sH/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pyt_archive_URLJscC@s|jdkrdSdS(sHandle the 'status' field.
        It seems that Launchpad tracks all 'debian' packages as 'Pending', while
        for 'ubuntu' we care about the 'Published' packages.
        tdebiantPendingt	Published(R(R((sH/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pyt_publication_statusPscC@sidd6dd6d|jfd6|jd6dd	6}|jd
k	red
|j|jf|d<n|jd
k	r|j|d<n|S(sGet the parameters defining our query.
        This defines the actions we are making against the archive.
        :return: A dict of query parameters.
        tgetPublishedSourcessws.opttruetexact_matchs"%s"tsource_nametstatust1sws.sizes/%s/%st
distro_seriestpocketN(RRRRRR(Rtparams((sH/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pyt
_query_params[s


cC@s;|j}tjt|j}d|j|fS(s@Create the full URL that we need to query, including parameters.s%s?%s(R"turllibt	urlencodetsortedtitemsR(RR!tencoded((sH/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pyt
_query_URLoscC@stdkrdS|j}y.tj|}tj|}|j}Wn>tjtjfk
r}t	j
d|ft	jdSX|S(s9Place an actual HTTP query against the Launchpad service.sfailed to place query to %rN(tjsonRR(turllib2tRequestturlopentreadtURLErrort	HTTPErrorRtmuttertlog_exception_quietly(Rt	query_URLtreqtresponset	json_infote((sH/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pyt_get_lp_infovs
cC@sXtdkrdSytj|SWn0tk
rStjd|ftjdSXdS(s4Parse the json response from Launchpad into objects.sFailed to parse json info: %rN(R)Rtloadst	ExceptionRR0R1(RR5((sH/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pyt_parse_json_infos

cC@s|j}|dkrdS|j|}|dkr;dSy0|d}t|dkr^dS|ddSWntk
rtjdSXdS(s7Get the latest published version for the given package.tentriesitsource_package_versionN(R7RR:tlentKeyErrorRR1(RR5tinfoR;((sH/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pytget_latest_versions


cC@sl|j}|jdk	r.d||jf}n|jdk	rb|jdkrbd||jf}n|jS(sText-form for what location this represents.

        Example::
            ubuntu, natty => Ubuntu Natty
            ubuntu, natty-proposed => Ubuntu Natty Proposed
        :return: A string representing the location we are checking.
        s%s %sR
N(RRRRR(Rtplace((sH/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pyRAs	(t__name__t
__module__t__doc__RRRRRR"R(R7R:R@RA(((sH/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pyR0s									cC@st|||}|jS(sGet the most recent publication for a given project.

    :param archive: Either 'ubuntu' or 'debian'
    :param series: Something like 'natty', 'sid', etc. Can be set as None. Can
        also include a pocket such as 'natty-proposed'.
    :param project: Something like 'bzr'
    :return: A version string indicating the most-recent version published in
        Launchpad. Might return None if there is an error.
    (RR@(RR	R
tlp((sH/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pytget_latest_publications
cC@std|jD}|jz_|j}|jj}dtjf}x.|j	||D]}||krf||SqfWWd|j
XdS(s2Get the most recent revision that has been tagged.cs@s!|]\}}||fVqdS(N((t.0ttagtrev((sH/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pys	<genexpr>sN(tdictt	iteritemst	lock_readt
last_revisiont
repositoryt	get_graphRRt
NULL_REVISIONtiter_lefthand_ancestrytunlock(ttag_dictt
the_branchtreverse_dicttlast_revtgraphtstop_revisionstrev_id((sH/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pytget_most_recent_tags
cC@stj}|j}tj|}tjd|f|dkrLdStj}|jj}tj|}tjd|f||kr||fSt||}||fSdS(sGet information about how 'fresh' this packaging branch is.

    :param the_branch: The Branch to check
    :param latest_pub: The LatestPublication used to check most recent
        published version.
    :return: (latest_ver, branch_latest_ver)
    s0LatestPublication.get_latest_version took: %.3fss*LatestPublication.get_tag_dict took: %.3fsN(NN(ttimeR@RR0Rttagstget_tag_dictRZ(RTt
latest_pubttt
latest_vertt_latest_verR\t
t_tag_dicttbest_tag((sH/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pyt_get_newest_versionss	
cC@s|dkrP|dkr,|d|fn |dkrL|d|fndS||kr|dkrldS|dkr|d||fq|d||fnR|dkr|dkrd	}n|d
|||fn|d|||fdS(
s#Report if the branch is up-to-date.tallsMost recent %s version: MISSINGtshorts%s is MISSING a versionNtminimals%s is CURRENT in %ss;Most recent %s version: %s
Packaging branch status: CURRENTtBranchs%s is OUT-OF-DATE, %s has %ss\Most recent %s version: %s
Packaging branch version: %s
Packaging branch status: OUT-OF-DATE(RgRf(R(R`tbranch_latest_verRAt	verbositytreport_func((sH/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pyt_report_freshnesss(	cC@sc|dkrdS|dkr%d}nt||\}}|j}t||||tjdS(sReport to the user how up-to-date the packaging branch is.

    :param the_branch: A Branch object
    :param verbosity: Can be one of:
        off: Do not print anything, and skip all checks.
        all: Print all information that we have in a verbose manner, this
             includes misses, etc.
        short: Print information, but only one-line summaries
        minimal: Only print a one-line summary when the package branch is
                 out-of-date
    :param latest_pub: A LatestPublication instance
    toffNRe(RRdRARlRtnote(RTRjR^R`t
branch_verRA((sH/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pytreport_freshnesss
	(RDt
__future__Rt
simplejsonR)tImportErrorRR[R#R*tbzrlibRRtobjectRRFRZRdRlRp(((sH/usr/lib/python2.7/dist-packages/bzrlib/plugins/launchpad/lp_api_lite.pyt<module>s$

				

Copyright © 2017 || Recoded By Mr.Bumblebee