ó `8(Zc@s|dZddlZddlZddlZddlZddlZddlmZdddddd gZej d d kre Z d „Z ne Z d „Z d„Zd„Zd„Zd„Zd„Zd„Zd„Zdefd„ƒYZdefd„ƒYZejdkr]ddlZeddddddƒZd „Zd!„Zd"„Znd#„Zd$„Zd%„Z dS(&sUtility functions.iÿÿÿÿN(t OrderedDictturlsafe_b64encodeturlsafe_b64decodetutf8tto_jsont from_jsontmatches_requirementiicCs|S(N((ts((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pytnativescCs t|tƒr|jdƒS|S(Ntascii(t isinstancetbytestdecode(R((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyRs cCstj|ƒjtdƒƒS(s!urlsafe_b64encode without paddingt=(tbase64Rtrstriptbinary(tdata((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyRscCs)ddt|ƒd@}tj||ƒS(s!urlsafe_b64decode without paddingR ii(tlenRR(Rtpad((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyR#scCstj|dtƒS(sConvert given data to JSON.t sort_keys(tjsontdumpstTrue(to((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyR)scCs tj|ƒS(sDecode a JSON payload.(Rtloads(tj((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyR.scCsItjddkr"i}d}nidd6}d}t||||S(Niitbttnewline(tsyst version_infotopen(tnametmodetnltbin((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyt open_for_csv3s   cCs t|tƒr|jdƒS|S(sUtf-8 encode data.sutf-8(R t text_typetencode(R((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyR>s cCs t|tƒr|jdƒS|S(NR (R R&R'(R((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyREs t HashingFilecBsAeZdd„Zd„Zd„Zd„Zd„Zd„ZRS(tsha256cCs:t||ƒ|_||_tj|ƒ|_d|_dS(Ni(R tfdthashtypethashlibtnewthashtlength(tselftpathR"R+((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyt__init__Ls cCs9|jj|ƒ|jt|ƒ7_|jj|ƒdS(N(R.tupdateR/RR*twrite(R0R((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyR4RscCs|jjƒdS(N(R*tclose(R0((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyR5WscCsF|jdkr|jjƒS|jjƒ}|jdtt|ƒƒS(Ntmd5R (R+R.t hexdigesttdigestRR(R0R8((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyR8Zs cCs|S(N((R0((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyt __enter__`scCs|jjƒdS(N(R*R5(R0texc_typetexc_valtexc_tb((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyt__exit__cs(t__name__t __module__R2R4R5R8R9R=(((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyR(Ks      tOrderedDefaultDictcBseZd„Zd„ZRS(cOsu|sd|_nF|ddkp/t|dƒsAtdƒ‚n|d|_|d}tt|ƒj||ŽdS(Nis'first argument must be callable or Nonei(tNonetdefault_factorytcallablet TypeErrortsuperR@R2(R0targstkwargs((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyR2hs    cCs6|jdkrt|ƒ‚n|jƒ||<}|S(N(RBRAtKeyError(R0tkeytdefault((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyt __missing__rs(R>R?R2RK(((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyR@gs twin32t CSIDL_APPDATAitCSIDL_LOCAL_APPDATAitCSIDL_COMMON_APPDATAi#cCsEd}tjtjjƒ}tjjjdt|d||ƒ|jS(Ni( tctypestcreate_unicode_buffertwintypestMAX_PATHtwindlltshell32tSHGetFolderPathWtcsidltvalue(R!tSHGFP_TYPE_CURRENTtbuf((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pytget_paths#cGsGtdƒ}tjj||Œ}tjj|ƒsCtj|ƒn|S(NRN(R[tosR1tjointisdirtmakedirs(tresourcetappdataR1((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pytsave_config_path…s  cgs\ddg}xI|D]A}t|ƒ}tjj||Œ}tjj|ƒr|VqqWdS(NRNRO(R[R\R1R]texists(R`tidstidtbaseR1((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pytload_config_pathsŒs    cGsddl}|jj|ŒS(Niÿÿÿÿ(txdg.BaseDirectoryt BaseDirectoryRb(R`txdg((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyRb”s cGsddl}|jj|ŒS(Niÿÿÿÿ(RhRiRg(R`Rj((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyRg˜s cCs°yddlm}m}Wntk r9tdƒ‚nX|j|ƒ}g}xZ|D]R}|j}|d|jdƒd|jdƒƒ}||krV|j|ƒqVqVW|S(s„List of wheels matching a requirement. :param req: The requirement to satisfy :param wheels: List of wheels to search. iÿÿÿÿ(t Distributiont Requirements-Cannot use requirements without pkg_resourcest project_nameR!tversiontver( t pkg_resourcesRkRlt ImportErrort RuntimeErrortparsetparsed_filenametgrouptappend(treqtwheelsRkRltselectedtwftftdist((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyRs   ' (!t__doc__RR,RR\Rt collectionsRt__all__RtunicodeR&RtstrRRRRR%RRtobjectR(R@tplatformtctypes.wintypesRPtdictRWR[RbRgR(((s)/tmp/pip-build-0nEYGB/wheel/wheel/util.pyts>