o U7eS#@sddlmZddlmZddlmZmZmZddlm Z m Z m Z ddl m Z ddlmZddlmZdZd Zeejeejd d gZd d gZGddde ZdS))gettext) Launchpad)NotFound BadRequest Unauthorized)ShortcutHandlerShortcutExceptionInvalidShortcutException)SourcesListShortcutHandler)URIShortcutHandler)urlparsez5https://ppa.launchpadcontent.net/{team}/{ppa}/ubuntu/z=https://private-ppa.launchpadcontent.net/{team}/{ppa}/ubuntu/zppa.launchpad.netzprivate-ppa.launchpad.netmain main/debugcseZdZdfdd ZeddZeddZedd Zed d Zed d Z eddZ d fdd Z fddZ ddZ ddZddZddZddZZS)!PPAShortcutHandlerFc  s,tt|j|fi|| |_d|_d|_d|_d|_d|_t | || || |fs9t d|}t|d|j|jf|_||jr\z|jWn ty[tt dw|js|j}|sodg}|jjrotd|jjrutnt}|j|j|jd}d|j||jd |f}| |dSdS) NFz%ERROR: '%s' is not a valid ppa formatz %s-ubuntu-%szERROR: Can't find ppar zDPPA publishes dbgsym, you may need to include 'main/debug' component)teamppaz %s %s %s %s )!superr__init___lp_anon_signing_key_data_lp_lpteam_lpppa_is_sourceslistany _match_ppa _match_uri_match_sourceslist_r teamnameppaname _filebase _set_authlpppar _source_entry componentspublish_debug_symbolsprintprivatePRIVATE_PPA_URI_FORMATPPA_URI_FORMATformat binary_typedistjoin_set_source_entry) selfshortcutloginkwargsmsgcomps uri_formaturiline __class__8/usr/lib/python3/dist-packages/softwareproperties/ppa.pyr2s@     zPPAShortcutHandler.__init__cCs>|js|jr tj}ntj}|d|j|jjfddd|_|jS)Nz%s.%s productiondevel) service_rootversion)rrrlogin_anonymously login_with __module__r;__name__)r1 login_funcr<r<r=lp[szPPAShortcutHandler.lpcCsl|js3z |j|j|_W|jSty!td|j}t|ty2td|j}t|w|jS)Nz8ERROR: user/team '%s' not found (use --login if private)z"ERROR: invalid user/team name '%s')rrGpeopler rrrrr1r5r<r<r=lpteamgs  zPPAShortcutHandler.lpteamcCst|js7z |jj|jd|_W|jSty%td|j|jf}t|ty6td|j}t|w|jS)N)namez5ERROR: ppa '%s/%s' not found (use --login if private)zERROR: invalid ppa name '%s') rrJ getPPAByNamer!rrr rrrIr<r<r=r$ts   zPPAShortcutHandler.lpppacC|jjSN)r$ descriptionr1r<r<r=rOzPPAShortcutHandler.descriptioncCrMrN)r$web_linkrPr<r<r=rRrQzPPAShortcutHandler.web_linkcCs~|js<|j}|jj}|sttdn$d|vr ttdn|||vr9td|d||f}t|||_|jS)NzHWarning: could not get PPA signing_key_fingerprint from LP, using anywayredactedzAPrivate PPA fingerprint redacted, using key anyway (LP: #1879781)z6Fingerprints do not match, not importing: '%s' != '%s',) rr$getSigningKeyDatasigning_key_fingerprintr(r fingerprintsr/r)r1key fingerprintr5r<r<r=trustedparts_contents z'PPAShortcutHandler.trustedparts_contentNcsDtt|j|d}||jks|jr|Stt|jtdg|_|S)N)pkgtyper)rr SourceEntry source_typer&listsetr6)r1r[entryr:r<r=r\s zPPAShortcutHandler.SourceEntrycsHtt||t|jtt}|r"ttdd |dSdS)Nz*Warning: components '%s' not valid for PPAr) rrr0r_r\r6PPA_VALID_COMPSr(rr/)r1r9 invalid_compsr:r<r=r0s z$PPAShortcutHandler._set_source_entrycCs|d\}}}|dksdS|d\}}}|d}d|vr7|d\}}}|dkr1dSd|vr7dS||_|p=d|_dS)N:rF/~ubuntuT) rpartitionlower partitionlstripr r!)r1r2prefixrrr r!rfr<r<r=rs    zPPAShortcutHandler._match_ppacCs&z|t|WStyYdSw)NF)_match_handlerr r )r1r2r<r<r=rs  zPPAShortcutHandler._match_uricCs2z |t|}Wn tyYdSwd|_|S)NFT)rlr r r)r1r2handlerr<r<r=rs z%PPAShortcutHandler._match_sourceslistcCszt|j}|jtvrdS|jdd}t|dkr!dS|d|_ |d|_ |j |_ |j |_||jdS)NFrdrT)r r\r8hostnamePPA_VALID_HOSTNAMESpathstripsplitlenr r!username _usernamepassword _passwordr0r9)r1rmparsedrrr<r<r=rls    z!PPAShortcutHandler._match_handlercCs|js|jjs dS|jr|jrdS|jjD] }t|}|j d|j d|j dr7|j |_|j|_dSqtd|j |j f}t|)Nrdz/ubuntuzMCould not find PPA subscription for ppa:%s/%s, you may need to request access)rr$r)rwryrGmegetArchiveSubscriptionURLsr rr startswithr r!rvrxrr)r1urlrzr5r<r<r=r#s  zPPAShortcutHandler._set_auth)FrN)rErD __qualname__rpropertyrGrJr$rOrRrZr\r0rrrrlr# __classcell__r<r<r:r=r1s*)       rN)rrlaunchpadlib.launchpadrlazr.restfulclient.errorsrrr"softwareproperties.shortcuthandlerrrr softwareproperties.sourceslistr softwareproperties.urir urllib.parser r+r*rprqrarr<r<r<r=s