Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/LanguageSelector/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/LanguageSelector/FontConfig.pyc


S/Oc@szddlZddlZddlmZddlZddlmZdefdYZdefdYZ	defd	YZ
d
efdYZe
dkrveZd
GejGHyejZWne	k
rdGHnXdGejdGHdGejGHydGejGHWne
k
r5dGHnXdGHejyejZdGHWqve	k
rrdGHqvXndS(iN(t
LocaleInfo(tlanguage2localetExceptionMultipleConfigurationscBseZdZRS(s- error when multiple languages are symlinked (t__name__t
__module__t__doc__(((s?/usr/lib/python2.7/dist-packages/LanguageSelector/FontConfig.pyRstExceptionUnconfiguredcBseZdZRS(s" error if no configuration is set (RRR(((s?/usr/lib/python2.7/dist-packages/LanguageSelector/FontConfig.pyRstExceptionNoConfigForLocalecBseZdZRS(s2 error if there is no config for the given locale (RRR(((s?/usr/lib/python2.7/dist-packages/LanguageSelector/FontConfig.pyRstFontConfigHackcBsSeZdZdddZdZdZdZdZdZd	Z	RS(
s abstract the fontconfig hack s/usr/share/language-selector/s
/etc/fontscCs5d||_||_||_td||_dS(Ns
%s/fontconfigtlanguagelist(tdatadirt_datadirt
globalConfDirRtli(tselfR
R((s?/usr/lib/python2.7/dist-packages/LanguageSelector/FontConfig.pyt__init__ s
		cCsQtjjtjj|d}|jdd\}}}d||jfS(s 
        internal helper to extracr from our fontconfig filenames
        of the form 69-language-selector-zh-tw.conf the locale
        and country

        returns string of the form locale_COUTNRY (e.g. zh_TW)
        it-is%s_%s(tostpathtsplitexttbasenametrsplittupper(Rtnametfnametheadtlltcc((s?/usr/lib/python2.7/dist-packages/LanguageSelector/FontConfig.pyt_getLocaleCountryFromFileName's"cCsGg}d|j}x-tj|D]}|j|j|q#W|S(sq get the configurations we have as a list of languages
            (returns a list of ['zh_CN','zh_TW'])
        s$%s/conf.avail/69-language-selector-*(RtglobtappendR(RtrestpatternR((s?/usr/lib/python2.7/dist-packages/LanguageSelector/FontConfig.pytgetAvailableConfigs2s

cCsid|j}tj|}t|dkr:tnt|dkrXtn|j|dS(s returns the current language configuration as a string (e.g. zh_CN)
        
            if the configfile is not a symlink it raises a
             ExceptionNotSymlink exception
            if the file dosn't exists raise a
             ExceptionUnconfigured exception
        s %s/conf.d/69-language-selector-*ii(RRtlenRRR(RR tcurrent_config((s?/usr/lib/python2.7/dist-packages/LanguageSelector/FontConfig.pytgetCurrentConfig;s
cCsMd|j}x9tj|D](}tjj|rtj|qqWdS(se removes the current fontconfig-voodoo configuration
            and do some sanity checking
        s%s/conf.d/*-language-selector-*N(RRRRtexiststunlink(RR tf((s?/usr/lib/python2.7/dist-packages/LanguageSelector/FontConfig.pytremoveConfigKs
c	Cstj|j|}|d}||jkr=tn|jd|j}xd|d|djfd|dgD]}x~tjt	j
j||D]^}t	j
j|}t	j
j|jd|}t	j
j|jd|}t	j
||qWqWtS(	s set the configuration for 'locale'. if locale can't be
            found a NoConfigurationForLocale exception it thrown
        tLOCALEs%s/conf.avail/s*-language-selector-%s-%s.conftLCODEtCCODEs*-language-selector-%s.confs
conf.availsconf.d(tmacrostLangpackMacrosRR!RR(RtlowerRRRtjoinRtsymlinktTrue(	RtlocaletmacrtbasedirR R'Rt	from_linktto_link((s?/usr/lib/python2.7/dist-packages/LanguageSelector/FontConfig.pyt	setConfigTs


%cCsX|jjd}t|dkr;|jjd}nt|}|j|dS(s set the configuration based on the locale in LocaleInfo. If
            no configuration is found the fontconfig config is set to
            'none'
            Can throw a exception
        iiN(R
tgetUserDefaultLanguageR"tgetSystemDefaultLanguageRR7(RtlangR2((s?/usr/lib/python2.7/dist-packages/LanguageSelector/FontConfig.pytsetConfigBasedOnLocaleks
(
RRRRRR!R$R(R7R;(((s?/usr/lib/python2.7/dist-packages/LanguageSelector/FontConfig.pyRs							t__main__savailable: tunconfiguredsset config: tzh_CNs	current: srun auto mode: sno config for this localesremoveConfig()s/ERROR: have config after calling removeConfig()sunconfigured (as expected)(Rtos.pathRRR,tutilsRt	ExceptionRRRtobjectRRtfcR!R$tconfigR7R;R((((s?/usr/lib/python2.7/dist-packages/LanguageSelector/FontConfig.pyt<module>
s8Z