;a udZeZdgZddlZddlZ ddlmZddl Z ddl m Z ddlmZmZmZmZddlmZdd lmZdd lmZmZmZmZmZmZmZm Z m!Z!dd l"m#Z#dd l$m%Z%m&Z&d Z'GddeZ(GddeZ)GddeZ*Gdde*Z+Gdde*Z,Gdde*Z-GddeZ.GddeZ/y#e$r ddl mZYwxYw#e$rddl m Z e jZ YwxYw)zRoot Launchpad API class. LaunchpadN)urlsplit)proxy_info_from_environment) ProxyInfo)CollectionWithKeyBasedLookup HostedFile ScalarValue ServiceRoot)SystemWideConsumer) RestfulHttp) AccessTokenAnonymousAccessToken AuthorizeRequestTokenWithBrowserAuthorizeRequestTokenWithURLConsumer CredentialsMemoryCredentialStoreKeyringCredentialStoreUnencryptedFileCredentialStore)uris)STAGING_SERVICE_ROOTEDGE_SERVICE_ROOTzhttps://api.launchpad.netceZdZdZdZdZy) PersonSetz7A custom subclass capable of person lookup by username.czt|jjjdzt|zS)z7Transform a username into the URL to a person resource.~str_root _root_uri ensureSlashselfkeys 8/usr/lib/python3/dist-packages/launchpadlib/launchpad.py_get_url_from_idzPersonSet._get_url_from_idJs.4::''3356SUDO_GIDSUDO_UID SUDO_USER)setosenvironkeys)clss r%_is_sudozLaunchpad._is_sudos4s2::??;L7MMMr'cB|jrt|St|SrE)rwrr)rvrJs r%authorization_engine_factoryz&Launchpad.authorization_engine_factorys# <<> 06 6/66r'cR|jr t|St|dS)NT)fallback)rwrr)rvcredential_save_faileds r%credential_store_factoryz"Launchpad.credential_store_factorys' <<> ))?@ @%&tjd|zty)NzThe Launchpad.%s() method is deprecated. You should use Launchpad.login_anonymous() for anonymous access and Launchpad.login_with() for all other purposes.)warningswarnDeprecationWarning)rvnames r%rz*Launchpad._warn_of_deprecated_login_methods# A    r'c @d}|||k7rt|||||||fzyy)aHelper to find conflicting values passed into the login methods. Many of the arguments to login_with are used to build other objects--the authorization engine or the credential store. If these objects are provided directly, many of the arguments become redundant. We'll allow redundant arguments through, but if a argument *conflicts* with the corresponding value in the provided object, we raise an error. zInconsistent values given for %s: (%r passed in, versus %r in %s). You don't need to pass in %s if you pass in %s, so just omit that argument.N)re)rv argument_nameargument_value object_value object_nameinconsistent_value_messages r%rz,Launchpad._assert_login_argument_consistencysP$ * #  %.L*H*!" !   +I %r'c| tjjdd}tjj|}|dddk(r t d tj |dtj|dtj|}t|\}}}}}tjj||} tjj| d} tj | d||| | fS#t $r(}|jtjk7rYd}~d}~wwxYw#t $r(}|jtjk7rYd}~fd}~wwxYw)aLocate launchpadlib-related user paths and ensure they exist. This is a helper function used by login_with() and login_anonymously(). :param service_root: The service root the user wants to connect to. This may be an alias (which will be dereferenced to a URL and returned) or a URL (which will be returned as is). :param launchpadlib_dir: The user's base launchpadlib directory, if known. This may be modified, expanded, or determined from the environment if missing. A definitive value will be returned. :return: A 4-tuple: (service_root_uri, launchpadlib_dir, cache_dir, service_root_dir) Nrz .launchpadlibzSMust set $HOME or pass 'launchpadlib_dir' to indicate location to store cached datairg) rspathjoin expanduserremakedirsOSErrorerrnoEEXISTchmodrrcr) rvrfrerrscheme host_namerqueryfragmentrrs r%rzLaunchpad._get_pathssD&  #!ww||CA 77--.>? BQ 3 &9   KK(% 0 !5)// = 3;L3I0 477<<(8)DWW\\"2G<   KK E *. rs"    "%=4  B3    *  ,  ) ,  $i$ #i# &!k&!R} N } NW"!" =""+"<"<=s"B9C 9 CC C$#C$