def __getitem__(self, args):
     if not isinstance(args, (tuple, list)):
         args = (args, )
     newchildren = self._children[:]
     stuff = [(x, stan.raw(',')) for x in args]
     if stuff:
         stuff[-1] = stuff[-1][0]
     newchildren.extend([stan.raw("["), stuff, stan.raw("]")])
     return self.__class__(newchildren)
Exemple #2
0
 def __getitem__(self, args):
     if not isinstance(args, (tuple, list)):
         args = (args,)
     newchildren = self._children[:]
     stuff = [(x, stan.raw(',')) for x in args]
     if stuff:
         stuff[-1] = stuff[-1][0]
     newchildren.extend([stan.raw("["), stuff, stan.raw("]")])
     return self.__class__(newchildren)
Exemple #3
0
def anonymous(block):
    """Turn block (any stan) into an anonymous JavaScript function
    which takes no arguments. Equivalent to

    function () {
        block
    }
    """
    return _js([stan.raw("function() {\n"), block, stan.raw("\n}")])
Exemple #4
0
def anonymous(block):
    """Turn block (any stan) into an anonymous JavaScript function
    which takes no arguments. Equivalent to

    function () {
        block
    }
    """
    return _js([stan.raw("function() {\n"), block, stan.raw("\n}")])
 def __call__(self, *args):
     if not self._children:
         return self.__class__(args[0])
     newchildren = self._children[:]
     stuff = []
     for x in args:
         if isinstance(x, (basestring, stan.Tag, types.FunctionType,
                           types.MethodType, types.UnboundMethodType)):
             x = stan.raw("'"), SingleQuote(x), stan.raw("'")
         stuff.append((x, stan.raw(',')))
     if stuff:
         stuff[-1] = stuff[-1][0]
     newchildren.extend([stan.raw('('), stuff, stan.raw(')')])
     return self.__class__(newchildren)
Exemple #6
0
 def __call__(self, *args):
     if not self._children:
         return self.__class__(args[0])
     newchildren = self._children[:]
     stuff = []
     for x in args:
         if isinstance(x, (
             basestring, stan.Tag, types.FunctionType,
             types.MethodType, types.UnboundMethodType)):
             x = stan.raw("'"), SingleQuote(x), stan.raw("'")
         stuff.append((x, stan.raw(',')))
     if stuff:
         stuff[-1] = stuff[-1][0]
     newchildren.extend([stan.raw('('), stuff, stan.raw(')')])
     return self.__class__(newchildren)
Exemple #7
0
 def fromString(klass, st):
     scheme, netloc, path, query, fragment = urlparse.urlsplit(st)
     u = klass(
         scheme, netloc,
         [raw(urllib.unquote(seg)) for seg in path.split('/')[1:]],
         unquerify(query), fragment)
     return u
 def __getattr__(self, name):
     if name == 'clone':
         raise RuntimeError("Can't clone")
     if self._children:
         newchildren = self._children[:]
         newchildren.append(stan.raw('.' + name))
         return self.__class__(newchildren)
     return self.__class__(name)
Exemple #9
0
 def __getattr__(self, name):
     if name == 'clone':
         raise RuntimeError("Can't clone")
     if self._children:
         newchildren = self._children[:]
         newchildren.append(stan.raw('.'+name))
         return self.__class__(newchildren)
     return self.__class__(name)
Exemple #10
0
def _uqf(query):
    for x in query.split('&'):
        if '=' in x:
            yield tuple([raw(urllib.unquote(s)) for s in x.split('=')])
        elif x:
            yield (raw(urllib.unquote(x)), None)
Exemple #11
0
def var(where, what):
    """Define local variable 'where' and assign 'what' to it.
    Equivalent to var where = what;
    """
    return _js([stan.raw("var "), where, stan.raw(" = "), what, stan.raw(";")])
Exemple #12
0
def assign(where, what):
    """Assign what to where. Equivalent to
    where = what;
    """
    return _js([where, stan.raw(" = "), what])
Exemple #13
0
 def __init__(self, name=None):
     if name is None:
         name = []
     if isinstance(name, str):
         name = [stan.raw(name)]
     self._children = name
Exemple #14
0
 def __init__(self, name=None):
     if name is None:
         name = []
     if isinstance(name, str):
         name = [stan.raw(name)]
     self._children = name
Exemple #15
0
def _uqf(query):
    for x in query.split("&"):
        if "=" in x:
            yield tuple([raw(urllib.unquote(s)) for s in x.split("=")])
        elif x:
            yield (raw(urllib.unquote(x)), None)
Exemple #16
0
def assign(where, what):
    """Assign what to where. Equivalent to
    where = what;
    """
    return _js([where, stan.raw(" = "), what])
Exemple #17
0
def _uqf(query):
    for x in query.split('&'):
        if '=' in x:
            yield tuple( [raw(urllib.unquote(s)) for s in x.split('=')] )
        elif x:
            yield (raw(urllib.unquote(x)), None)
Exemple #18
0
 def returnEntry(ret=None):
     print data
     if data:
         return stan.raw(snomDevConf % data)
     return ""
Exemple #19
0
def var(where, what):
    """Define local variable 'where' and assign 'what' to it.
    Equivalent to var where = what;
    """
    return _js([stan.raw("var "), where, stan.raw(" = "), what, stan.raw(";")])
Exemple #20
0
 def fromString(klass, st):
     scheme, netloc, path, query, fragment = urlparse.urlsplit(st)
     u = klass(scheme, netloc,
               [raw(urllib.unquote(seg)) for seg in path.split('/')[1:]],
               unquerify(query), fragment)
     return u
Exemple #21
0
    def render_raw_header(self, ctx, data):
        """Render the top raw header."""
        return stan.raw('''\
<!--[if gte IE 5.5000]>
  <script type="text/javascript" src="/js/pngfix.js"></script>
<![endif]-->''')