ó i'dWc@sçdZddlZddlmZddlmZddlmZdZ dZ dZ d Z d Z d Zd ejfd „ƒYZejeƒZdeje fdejfdejfdefdejfge_dejfd„ƒYZejeƒZdeje fdejfdejfdejfdefdejfge_dejfd„ƒYZdejfd„ƒYZejeƒZdeje fd eje fd!ejfd"ejfd#efd$efd%ejfge_ejd&ƒZejZ eje _!ejeƒfe _"ej#Z$eje$_!ejeƒefe$_"ej%Z&eje&_!ejeƒefe&_"ej'Z(eje(_!efe(_"ej)Z*eje*_!efe*_"ej+Z,eje,_!efe,_"ej-Z.eje._!ejejejfe._"ej/Z0eje0_!ejfe0_"ed'd(d)d*gƒZ1ed+d,d)d*gƒZ2ed-d.d/d0d1gƒZ3ed2d(d3d)d*d4d5gƒZ4d6„Zd7„Z#d8„Z%d9ed:„Z-d9d;„Z/d<„Z5dS(=s Python package with ctypes wrapper for libzoneinfo. Example usage: import libzoneinfo as zi continent = reduce(lambda x, y: x or y.name=="Europe" and y, zi.get_tz_continents(), None) country = reduce(lambda x, y: x or y.code == "IE" and y, zi.get_tz_countries(continent), None) zone = reduce(lambda x, y: x or y.oname.endswith("Dublin") and y, zi.get_timezones_by_country(country), None) zi.isvalid_tz(zone.oname) zi.get_system_tz() iÿÿÿÿN(t namedtuple(tENOMEM(tstrerrori€i iiiit _TZContinentcBseZRS((t__name__t __module__(((slibzoneinfo.pyR>st ctnt_namet ctnt_id_desctctnt_display_desct ctnt_nextt ctnt_reservedt _TZCountrycBseZRS((RR(((slibzoneinfo.pyR Lst ctry_codet ctry_id_desctctry_display_desct ctry_statust ctry_nextt ctry_reservedt_TZCoordc BsneZdejfdejfdejfdejfdejfdejfdejfdejfgZRS(tlat_signt lat_degreet lat_minutet lat_secondt long_signt long_degreet long_minutet long_second(RRtCtc_inttc_uintt_fields_(((slibzoneinfo.pyR[s       t _TZTimezonecBseZRS((RR(((slibzoneinfo.pyRhsttz_namettz_onamet tz_id_descttz_display_descttz_coordttz_nextt tz_reserveds/usr/lib/libzoneinfo.sotTZContinentInfotnamet descriptiontl10nt TZCountryInfotcodet TZCoordInfotsigntdegreetminutetsecondtTZTimezoneInfotonametlatitudet longitudecCsÎtƒ}ttj|ƒƒ}|dkrmtjƒ}|tkrQtdƒ‚nt|dt|ƒƒ‚nt ƒ}|}xA|r¿|j t |j j |j j|j jƒƒ|j j}qWt|ƒ|S(sZ get_tz_continents(None) -> list of TZContinentInfo This list is not sorted. iÿÿÿÿs(get_tz_continents(): insufficient memorysget_tz_continents(): %s(t _TZContinentpt_get_tz_continentsRtbyreft get_errnoRt MemoryErrortOSErrorRtlisttappendR'tcontentsRRRR t_free_tz_continents(theadtcountterrtresulttitr((slibzoneinfo.pytget_tz_continents¥s         cCs7t|tƒstdƒ‚ntƒ}|j|_|j|_|j|_ d|_ d|_ t ƒ}ttj|ƒtj|ƒƒ}|dkrÖtjƒ}|tkrºtdƒ‚nt|dt|ƒƒ‚ntƒ}|}xA|r(|jt|jj|jj|jjƒƒ|jj}qèWt|ƒ|S(s| get_tz_countries(TZContinentInfo) -> list of TZCountryInfo The list is sorted by the localized country names. s#continent must be a TZContinentInfoiÿÿÿÿs'get_tz_countries(): insufficient memorysget_tz_countries(): %sN(t isinstanceR't TypeErrorRR(RR)RR*RtNoneR R t _TZCountrypt_get_tz_countriesRR8R9RR:R;RR<R=R+R>R R RRt_free_tz_countries(t continenttctntR@RARBRCRD((slibzoneinfo.pytget_tz_countriesÂs0       !       c Cs²t|tƒstdƒ‚ntƒ}|j|_|j|_|j|_ d|_ d|_ d}t ƒ}ttj|ƒtj|ƒƒ}|dkrÜtjƒ}|tkrÀtdƒ‚nt|dt|ƒƒ‚ntƒ}|}x¶|r£|jt|jj|jj|jj|jjt|jjj |jjj!|jjj"|jjj#ƒt|jjj$|jjj%|jjj&|jjj'ƒƒƒ|jj(}qîWt)|ƒ|S(s~ get_timezones_by_country(TZContinentInfo) -> list of TZCountryInfo Returns a list of timezones for the country. s!continent must be a TZCountryInfoiiÿÿÿÿs'get_tz_countries(): insufficient memorysget_tz_countries(): %sN(*RFR+RGR R,R R)R R*RRRHRt _TZTimezonept_get_timezones_by_countryRR8R9RR:R;RR<R=tTZInfoR>R R!R"R#R-R$RRRRRRRRR%t_free_timezones(tcountrytctryRR@RARBRCRD((slibzoneinfo.pytget_timezones_by_countryèsD       !             t/cCst|tƒstdƒ‚nt|tƒs<tdƒ‚nt|tƒsZtdƒ‚n|ttttfkrtdƒ‚nt |||ƒ}|dkS(sL isvalid_tz(str, str, int) -> bool validate a timezone string. stimezone must be a strsroot must be a strsflag must be ints?flag must be in (VTZ_INSTALL, VTZ_ALL, VTZ_POSIX, VTZ_ZONEINFO)i( RFtstrRGtintt VTZ_INSTALLtVTZ_ALLt VTZ_POSIXt VTZ_ZONEINFOt ValueErrort _isvalid_tz(ttimezonetroottflagRC((slibzoneinfo.pyt isvalid_tzscCswt|tƒstdƒ‚nt|ƒ}|sstjƒ}|tkrWtdƒ‚nt|dt |ƒƒ‚n|S(sN get_system_tz(str) -> str look up the systems current timezone. sroot must be a strs(get_tz_continents(): insufficient memorysget_tz_continents(): %s( RFRWRGt_get_system_tzRR9RR:R;R(R`RCRB((slibzoneinfo.pyt get_system_tz/s   cCs[tƒ}xKtƒD]@}tƒ}x$t|ƒD]}t|ƒ|| TZCountryInfo -> [TZInfo] (tdictRERNRU(touterRLtinnerRS((slibzoneinfo.pyt get_tz_infoAs  (6t__doc__tctypesRt collectionsRterrnoRtosRt _TZBUFLENt _CCBUFLENRYRZR[R\t StructureRtPOINTERR6tc_chartc_char_ptc_void_pRR RIRRRROtCDLLt _LIBZONEINFORER7trestypetargtypesRNRJRURPtfree_tz_continentsR?tfree_tz_countriesRKtfree_timezonesRRRbR^RdRcR'R+R-RQRh(((slibzoneinfo.pyt.s–                                   & 1