OӈUc @sdZddkZddkZddkZddkZddkZddkTeidZ e ge i _ eidZ e eeege i_ e e i_e ge i_ ee i_e ge i_ dZeidZe ei_eeeeegei_ e eegei_ eei_e eegei_ eei_e egei_ eei_e eegei_ eei_e egei_ eeei_e egei_ e ei_e egei!_ e ei!_e eegei"_ eeei"_e gei#_ e ei#_dd >Z$dd>Z%dd >Z&dd >Z'dd >Z(dd >Z)dd>Z*dd>Z+dd>Z,hdd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd(6d)d*6d+d,6d-d.6d/d06d/d16d2d36d%d46d5d66Z-hd7d86d7d96d7d:6dd;6Z.e/Z0d<e1d=Z2d>fd?YZ3d@fdAYZ4dBe5fdCYZ6dS(Ds# Locale Services Library (g11nsvc) iN(t*slibc.sos libscf.socCswd}tid|||}|dj oHti|}|dj o|djo |}qbnti|n|S(Nt(tNonet_libscftscf_simple_prop_gettscf_simple_prop_next_astringtscf_simple_prop_free(tinsttpgnametvartrettproptval((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyt_libscf_prop_get!s   s libnlsadm.soiiiiiiiiitcp1251tANSI1251tbig5tBIG5t big5hkscstBIG5HKteuc_jpteucJPtgb18030tGB18030tgbktGBKtlatin_1s ISO8859-1t iso8859_2s ISO8859-2t iso8859_5s ISO8859-5t iso8859_6s ISO8859-6t iso8859_7s ISO8859-7t iso8859_8s ISO8859-8t iso8859_9s ISO8859-9t iso8859_13s ISO8859-13t iso8859_15s ISO8859-15tkoi8_rskoi8-rsKOI8-Rt shift_jistPCKt sun_eu_greektutf_8sUTF-8tasciitCtPOSIXt en_US_POSIXt iso_8859_1t/cCsxM|djo ttgn|gD](}||ftjot||fSq$W|djo t}ntt}ti||t|}d}|o7t |}t i |t i d|tddn|ptd|n|t||f<|S(NRs tg11nsvcs" libnlsadm initialization error %s(RtFalsetTruet_cachetPOINTERtc_chart_libnlst nlsadm_inittbyreft string_att_libctfreetwarningst showwarningt UserWarningtG11nSvcLibNlsadmError(t image_dirt local_onlytit pkg_stderrtnlsterr((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyt _libnls_initrs"$    tG11NSvcLocalePopulatecBs&eZdZdedZdZRS(sG This class uses libnlsadm to get a list of valid locales. If setlocale_check is True the list will contain only locales installed on the system, if setlocale_check is False the list will include not only installed locales but also locales available for installation from IPS package repositories. Default values of locale_search_path='/usr/lib/locale' and setlocale_check=True work well on an installed Solaris system. If this is called from an image rooted at a diferent location than the default locale_search_path value, then locale_search_path should point to the path of the image rooted where the locale directories are found. If specified, the locale_search_path should end with '/usr/lib/locale' (e.g. '/root_image/usr/lib/locale'). If this is called from an installation media such as a CD-ROM setlocale_check should be set to False. G11NSvcLocalePopulate has a method get_valid_locales which returns a list of locales provided by libnlsadm. s/usr/lib/localec CsRtii|}|idptd|nt|td |}ti|t }g}t i d|D]C}|t jpti ||djo|ti||q|q|~|_g}|iD]!}||djodn|q~|_g} |iD]!}| |djodn|q~ |_ti|dS(Ns/usr/lib/locales( '%s' is not a valid locale_search_path susr/lib/localecSs|S(((ty((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pytsiR*R)(tostpathtabspathtendswithR=RDtlenR4tnlsadm_get_allt_NLSADM_TYPE_LOCALEt itertoolst takewhileR/tnlsadm_is_installedt nlsadm_to_strt valid_localesR8R9( tselftlocale_search_pathtsetlocale_checkR>RBtloc_idst_[1]txt_[2]t_[3]((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyt__init__s <;;cCs|iS(N(RS(RT((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pytget_valid_localess(t__name__t __module__t__doc__R0R\R](((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyREs tG11NSvcLocaleOperationscBsveZdZdZgddZddZeidZ ddZ ddZ ddZ ddZ ddd Zddd Zddd Zdd Zdd ZddZddZddZddZddddddZddZddZddeddZdZdddZdZdZdZ dZ!dZ"dZ#RS(s libnlsadm handler (singleton) s/etc/default/initcCs<|i|_||_|idodnd|_dS(s Valid_locales is the list of valid locales. The init_file parameter is obsolete and should not be used, it has not been removed to keep compatibility with older code. The init_file is not longer necessary and will be ignored. s en_US.UTF-8R)N(t getlocalet _curr_loct_valid_localest _get_loc_idt _fallback_loc(RTRSt init_file((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyR\s cCsAy#titi||_|iSWntij odSXdS(s Sets the given locale for a system in the LC_ALL locale environment. Returns the name of the locale set or None if the locale is not supported. N(tlocalet setlocaletLC_ALLRctErrorR(RTt localename((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyRis  cCsHyti|dSWn-tij otidtdddSXdS(s Gets the currently set locale for a system. By default, the LC_CTYPE locale environment is used. Rs,Unable to set locale, reverting to C locale.R.R)N(RhRiRkR:R;R<(RTtcategory((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyRbs   cCs"|djo|i|tSdS(s Gets the language code from a locale. A language code is in most cases an ISO 639 two-letter code. If localename is None, the default locale is used. :param localename str: locale name R)R*R+ten(R)sPOSIXR+(t _get_loc_propt_NLSADM_TYPE_LANGUAGE(RTRl((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pytget_language_codes cCs|i|tS(s Gets the territory code from locale name. A territory code is in most cases an ISO 3166 two-letter code. If localename is None, the default locale is used. :param localename str: locale name (Rot_NLSADM_TYPE_TERRITORY(RTRl((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pytget_territory_codescCs|i|tS(s Gets the codeset of the localename. If localename is None, the default locale is used. :param localename str: locale name (Rot_NLSADM_TYPE_CODESET(RTRl((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyt get_encodingscCs|i|tS(s Get the variant of the localename. If localename is None, the default locale is used. :param localename str: locale name (Rot_NLSADM_TYPE_MODIFIER(RTRl((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyt get_variant scCs%|i||t}|i||S(s, Gets the language description from locale name. Returns description in desc_locale if available (return value is 'None' if language description is not available in desc_locale). If the codeset of desc_locale is not supported by python codecs, output will be in UTF-8. If the value of localename or desc_locale is None, the default locale is used. :param localename str: locale name :param desc_locale str : locale for language description output. (t_get_loc_prop_nativeRpt_convert_to_target_encoding(RTRlt desc_localetlang((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pytget_language_descs  cCs%|i||t}|i||S(s. Gets the territory description from locale name. Returns description in desc_locale if available (return value is 'None' if territory description is not available in desc_locale). If the codeset of desc_locale is not supported by python codecs, output will be in UTF-8. If the value of localename or desc_locale is None, the default locale is used. :param localename str: locale name :param desc_locale str: locale for territory description output. (RxRrRy(RTRlRztterr_str((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pytget_territory_desc$s  cCs%|i||t}|i||S(s& Gets territory and language description from locale name. Returns description in desc_locale if available (return value is 'None' if locale description is not available in desc_locale). If the codeset of desc_locale is not supported by python codecs, output will be in UTF-8. If the value of localename or desc_locale is None, the default locale is used. :param localename str: locale name :param desc_locale str: locale for locale description output. (RxRNRy(RTRlRztloc_str((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pytget_locale_desc5s  cCs|id|S(sq Gets a list of all locales with lang_code. :param lang_code str - language code. t lang_code(t get_locales(RTR((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pytget_locales_with_language_codeEscCs|id|S(s{ Gets a list of all locales with territory_code. :param territory_code str: territory code. tterritory_code(R(RTR((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pytget_locales_with_territory_codeMscCs|id|S(sh Gets a list of all locales with encoding. :param encoding str: codeset. tencoding(R(RTR((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pytget_locales_with_encodingUscCs|id|S(sk Gets a list of all locales with variant. :param variant str: variant code. tvariant(R(RTR((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pytget_locales_with_variant]scCs|id|ddS(sv Gets a list of all UTF-8 locales with lang_code. :param lang_code str: language code. RRsUTF-8(R(RTR((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pytget_utf8_localesfscCs|id|dtS(sw Gets a list of all legacy locales with lang_code. :param lang_code str: language code. Rtlegacy(RR0(RTR((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pytget_legacy_localesoscCs|ipti|_ng}|iD]}|djp|i||jo|djp|i||jot|djp|i||joQ|djp|i||jo.|djp|i||jo ||q.q.~S(sG Calls component functions to return a list of locales obeying language/territory/encoding and variant constraints. If for a parameter None is passed then the component function returns all the valid locales. This enables us to pass the needed params we are interested in and output the intersection of results for the components. :param lang_code str: language code :param territory str: territory code :param encoding str: codeset :param variant str: variant. N( RdRER]RRqRsRuRwt_get_loc_is_legacy(RTRRRRRRXRY((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyRxs      cCsQg}xD|iD]6}|i||}|dj o|i|qqW|S(s Gets the description of all UTF-8 locales in desc_locale. If desc_locale is None, the default locale is used. :param desc_locale str: locale for locale description output. N(RRRtappend(RTRztdesc_arrtitemtdesc((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pytget_utf8_locales_descs  csmipti_n|djotidSttfdid|DS(s Returns a list of timezones for territory_code. If territory_code is None, the territory code for the current locale is used. :param territory_code str: Region code c3s3x,|]%}xi|D] }|VqWqWdS(N(t_get_timezones_for_locale(t.0tlocttz(RT(so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pys s RN(RdRER]RtlistRtsetR(RTR((RTso/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pytget_timezones_for_territorys   csmipti_nid|d|}djo|Sttfd|DS(sf Returns a list of locales for a timezone, a lang_code and an encoding. If check_locale is False, the list will include not only installed locales but also locales available for installation from IPS package repositories. :param timezone str: Timezone :param lang_code str: Language Code :param locale_check bool: Boolean value indicating if the resultant localename needs to be verified. :param encoding str: Encoding of the locale to be returned. RRc3sDx=|]6}x-i|D]}|jo |VqqWqWdS(N(R(RRR(RTttimezone(so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pys s N(RdRER]RRRR(RTRRt check_localeRtlocs((RTRso/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pytget_localename_from_timezones   cCs<x5dddgD]$}tdd|}|o|SqWdS(s Gets the value of the default system locale that is managed through the service management facility SMF under the service identifier: svc:/system/environment:init RjtLC_CTYPEtLANGssvc:/system/environment:initt environmentR)(R (RTR R ((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pytget_default_system_locales  cCs|djo|S|tjot|}n|i|}|tjot|}n{|djo |i|djo d}nN|djo |i|djo d}n!tid|tddd }ti ||d S( NtEUCtzhtgb2312tkoteuc_krs#Output in %s not supported. Using CR.RR(treplace( Rt_NO_CODESET_LOCALESRut_NLSADM_PYTHON_ENCODING_MAPRqR:R;R<tcodecstencode(RTttextRzt pyt_codectcodec((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyRys   # #  cCsE|ipt|_nti|i|o|n|ittBS(N(t_nlsRDR4tnlsadm_from_strRcRNt_NLSADM_TYPE_ALIAS(RTR((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyRes   cCs4|i|}|oti|i|djSdS(Ni(ReR4tnlsadm_locale_is_legacyR(RTRtloc_id((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyRscCs1|i|}|oti|i||SdS(N(ReR4tnlsadm_locale_get_attrR(RTRtnls_typeR((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyt_get_loc_prop_id scCsR|i||}|o5ti|i|}|djodS|idSdS(Ntutf8(RR4RRRRtdecode(RTRRtattr_idtout((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyRoscCs|tjo |i}n|i|}|i||}|o?|o8ti|i||}|djodS|idSdS(NR( RRfReRR4tnlsadm_to_native_nameRRR(RTRtdesc_locRtdesc_idRR((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyRxs  ccsw|i|}|o]ti|i|t}x1tid|D]}ti|i|VqDWti |ndS(NcSs|S(((RF((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyRG(s( ReR4tnlsadm_locale_get_vattrRt_NLSADM_TYPE_TIMEZONERORPRRR8R9(RTRRttz_idsRY((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyR"s N($R^R_R`RRR\RiRhRRbRqRsRuRwR|R~RRRRRRRRRRR0RRRyReRRRoRxR(((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyRas@             R=cBseZdZRS(sF Exception raised when libnlsadm fails and returns error. (R^R_R`(((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyR=.s(7R`RhR:RRHROtctypestcdllt LoadLibraryR8tc_void_pR9targtypesRtc_char_pRtrestypeRRR R4R5tc_boolR2R3tc_uintRRRRRRMRtc_intRQRt nlsadm_finiRNRRpRrRtRvRt_NLSADM_TYPE_PACKAGEt_NLSADM_TYPE_FACETRRtdictR1RRDRERat ExceptionR=(((so/scratch/g11nbld/nightly.26.2/g11n-oso/proto/i386/fileroot/usr/lib/python2.6/vendor-packages/g11nsvc/g11nsvc.pyt s<     !                   1r