python类Node()的实例源码

static.py 文件源码 项目:CodingDojo 作者: ComputerSocietyUNB 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def handle_token(cls, parser, token):
        """
        Class method to parse prefix node and return a Node.
        """
        bits = token.split_contents()

        if len(bits) < 2:
            raise template.TemplateSyntaxError(
                "'%s' takes at least one argument (path to file)" % bits[0])

        path = parser.compile_filter(bits[1])

        if len(bits) >= 2 and bits[-2] == 'as':
            varname = bits[3]
        else:
            varname = None

        return cls(varname, path)
static.py 文件源码 项目:lifesoundtrack 作者: MTG 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def handle_token(cls, parser, token):
        """
        Class method to parse prefix node and return a Node.
        """
        bits = token.split_contents()

        if len(bits) < 2:
            raise template.TemplateSyntaxError(
                "'%s' takes at least one argument (path to file)" % bits[0])

        path = parser.compile_filter(bits[1])

        if len(bits) >= 2 and bits[-2] == 'as':
            varname = bits[3]
        else:
            varname = None

        return cls(varname, path)
static.py 文件源码 项目:djanoDoc 作者: JustinChavez 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def handle_token(cls, parser, token):
        """
        Class method to parse prefix node and return a Node.
        """
        bits = token.split_contents()

        if len(bits) < 2:
            raise template.TemplateSyntaxError(
                "'%s' takes at least one argument (path to file)" % bits[0])

        path = parser.compile_filter(bits[1])

        if len(bits) >= 2 and bits[-2] == 'as':
            varname = bits[3]
        else:
            varname = None

        return cls(varname, path)
comments.py 文件源码 项目:tissuelab 作者: VirtualPlants 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def handle_token(cls, parser, token):
        """Class method to parse render_comment_form and return a Node."""
        tokens = token.split_contents()
        if tokens[1] != 'for':
            raise template.TemplateSyntaxError("Second argument in %r tag must be 'for'" % tokens[0])

        # {% render_comment_form for obj %}
        if len(tokens) == 3:
            return cls(object_expr=parser.compile_filter(tokens[2]))

        # {% render_comment_form for app.models pk %}
        elif len(tokens) == 4:
            return cls(
                ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
                object_pk_expr = parser.compile_filter(tokens[3])
            )
comments.py 文件源码 项目:tissuelab 作者: VirtualPlants 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def handle_token(cls, parser, token):
        """Class method to parse render_comment_list and return a Node."""
        tokens = token.split_contents()
        if tokens[1] != 'for':
            raise template.TemplateSyntaxError("Second argument in %r tag must be 'for'" % tokens[0])

        # {% render_comment_list for obj %}
        if len(tokens) == 3:
            return cls(object_expr=parser.compile_filter(tokens[2]))

        # {% render_comment_list for app.models pk %}
        elif len(tokens) == 4:
            return cls(
                ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
                object_pk_expr = parser.compile_filter(tokens[3])
            )
activity_tags.py 文件源码 项目:mes 作者: osess 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def handle_token(cls, parser, token):
        """
        Class method to parse and return a Node.
        """
        bits = token.split_contents()
        args_count = len(bits) - 1
        if args_count >= 2 and bits[-2] == 'as':
            as_var = bits[-1]
            args_count -= 2
        else:
            as_var = None
        if args_count != cls.args_count:
            arg_list = ' '.join(['[arg]' * cls.args_count])
            raise TemplateSyntaxError("Accepted formats {%% %(tagname)s "
                "%(args)s %%} or {%% %(tagname)s %(args)s as [var] %%}" %
                {'tagname': bits[0], 'args': arg_list})
        args = [parser.compile_filter(token) for token in
            bits[1:args_count + 1]]
        return cls(args, varname=as_var)
static.py 文件源码 项目:django-next-train 作者: bitpixdigital 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def handle_token(cls, parser, token):
        """
        Class method to parse prefix node and return a Node.
        """
        bits = token.split_contents()

        if len(bits) < 2:
            raise template.TemplateSyntaxError(
                "'%s' takes at least one argument (path to file)" % bits[0])

        path = parser.compile_filter(bits[1])

        if len(bits) >= 2 and bits[-2] == 'as':
            varname = bits[3]
        else:
            varname = None

        return cls(varname, path)
static.py 文件源码 项目:django-wechat-api 作者: crazy-canux 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def handle_token(cls, parser, token):
        """
        Class method to parse prefix node and return a Node.
        """
        bits = token.split_contents()

        if len(bits) < 2:
            raise template.TemplateSyntaxError(
                "'%s' takes at least one argument (path to file)" % bits[0])

        path = parser.compile_filter(bits[1])

        if len(bits) >= 2 and bits[-2] == 'as':
            varname = bits[3]
        else:
            varname = None

        return cls(varname, path)
log.py 文件源码 项目:CodingDojo 作者: ComputerSocietyUNB 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __repr__(self):
        return "<GetAdminLog Node>"
static.py 文件源码 项目:CodingDojo 作者: ComputerSocietyUNB 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def handle_token(cls, parser, token, name):
        """
        Class method to parse prefix node and return a Node.
        """
        # token.split_contents() isn't useful here because tags using this method don't accept variable as arguments
        tokens = token.contents.split()
        if len(tokens) > 1 and tokens[1] != 'as':
            raise template.TemplateSyntaxError(
                "First argument in '%s' must be 'as'" % tokens[0])
        if len(tokens) > 1:
            varname = tokens[2]
        else:
            varname = None
        return cls(varname, name)
log.py 文件源码 项目:NarshaTech 作者: KimJangHyeon 项目源码 文件源码 阅读 51 收藏 0 点赞 0 评论 0
def __repr__(self):
        return "<GetAdminLog Node>"
log.py 文件源码 项目:Scrum 作者: prakharchoudhary 项目源码 文件源码 阅读 48 收藏 0 点赞 0 评论 0
def __repr__(self):
        return "<GetAdminLog Node>"
urlcompass.py 文件源码 项目:django-urlcompass 作者: Acrisel 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def urlcompass_step(parser, token):
    """returns object of __UrlCompassStepNode subclass of django template node object

        This functions assumes urlcompass_show is already used in the template.
        hence, it access session data sets maintained by urlcompass_show:

        :param parser: django parser object
        :param token: django token object
        :returns: __UrlCompassStepNode
        :rtype: django_template.Node

        :Example:

        {% urlcompass_step <view> %}

    """  


    # analyse toekn for start and wep overrides
    parts=token.split_contents()
    if len(parts) != 1:
        raise django_template.TemplateSyntaxError("'urlcompass_step' accepts one and only one argument: {% url_compass_step <view> %}")

    view=parts[0].strip()

    return __UrlCompassStepNode(view)
sql.py 文件源码 项目:tumanov_castleoaks 作者: Roamdev 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def get_stack_calls():
    stack = []
    currentframe = inspect.currentframe()
    if currentframe is None:
        return stack

    try:
        stackframes = inspect.getouterframes(currentframe)
    except IndexError:
        # ???????? ?????? Jinja2
        stackframes = traceback.extract_stack()
        for record in stackframes[2:]:
            filename, lineno, funcname, line = record
            if filename.startswith(BASE_PATTERN) and 'devserver' not in filename:
                filename = filename[len(BASE_PATTERN):]
                caller = '%s (func %r, line %s)' % (filename, funcname, lineno)
                stack.append(caller)
    else:
        for record in stackframes[2:]:
            frame, filename, lineno, funcname, lines, index = record
            if filename in (TEMPLATE_BASE, TEMPLATE_DEBUG):
                # ????? ?? ???????
                node = frame.f_locals.get('node') or frame.f_locals.get('self')
                if isinstance(node, Node):
                    loader = node.source[0]
                    offsets = node.source[1]
                    with open(loader.name, newline='') as source:
                        start = source.read(offsets[0])
                        line_num = start.count('\n') + 1
                        token = source.read(offsets[1] - offsets[0])

                    caller = '%s (node %r, line %s)' % (loader.loadname, token, line_num)
                    stack.append(caller)
                    break
            elif filename.startswith(BASE_PATTERN) and 'devserver' not in filename:
                # ????? ?? ????
                filename = filename[len(BASE_PATTERN):]
                caller = '%s (func %r, line %s)' % (filename, funcname, lineno)
                stack.append(caller)

    return reversed(stack)
log.py 文件源码 项目:Gypsy 作者: benticarlos 项目源码 文件源码 阅读 50 收藏 0 点赞 0 评论 0
def __repr__(self):
        return "<GetAdminLog Node>"
log.py 文件源码 项目:DjangoBlog 作者: 0daybug 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __repr__(self):
        return "<GetAdminLog Node>"
log.py 文件源码 项目:wanblog 作者: wanzifa 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __repr__(self):
        return "<GetAdminLog Node>"
log.py 文件源码 项目:tabmaster 作者: NicolasMinghetti 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def __repr__(self):
        return "<GetAdminLog Node>"
log.py 文件源码 项目:trydjango18 作者: lucifer-yqh 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def __repr__(self):
        return "<GetAdminLog Node>"
log.py 文件源码 项目:trydjango18 作者: wei0104 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __repr__(self):
        return "<GetAdminLog Node>"
log.py 文件源码 项目:ims 作者: ims-team 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def __repr__(self):
        return "<GetAdminLog Node>"
log.py 文件源码 项目:lifesoundtrack 作者: MTG 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __repr__(self):
        return "<GetAdminLog Node>"
static.py 文件源码 项目:lifesoundtrack 作者: MTG 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def handle_token(cls, parser, token, name):
        """
        Class method to parse prefix node and return a Node.
        """
        # token.split_contents() isn't useful here because tags using this method don't accept variable as arguments
        tokens = token.contents.split()
        if len(tokens) > 1 and tokens[1] != 'as':
            raise template.TemplateSyntaxError(
                "First argument in '%s' must be 'as'" % tokens[0])
        if len(tokens) > 1:
            varname = tokens[2]
        else:
            varname = None
        return cls(varname, name)
workflow_tags.py 文件源码 项目:django-icekit 作者: ic-labs 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __repr__(self):
        return "<GetAssigedToUser Node>"
log.py 文件源码 项目:django-open-lecture 作者: DmLitov4 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __repr__(self):
        return "<GetAdminLog Node>"
log.py 文件源码 项目:travlr 作者: gauravkulkarni96 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __repr__(self):
        return "<GetAdminLog Node>"
log.py 文件源码 项目:logo-gen 作者: jellene4eva 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __repr__(self):
        return "<GetAdminLog Node>"
log.py 文件源码 项目:liberator 作者: libscie 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __repr__(self):
        return "<GetAdminLog Node>"
pagenav.py 文件源码 项目:studentsdb2 作者: trivvet 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def pagenav(page_obj, is_paginated, paginator):
    # Display page navigation for given list of objects
    return {
        'page_obj': page_obj,
        'is_paginated': is_paginated,
        'paginator': paginator
    }

#@register.tag
#def pagenav(parser, token):
    ## This version uses a regular expression to parse tag contents.
    #try:
        ## Splitting by None == splitting by spaces.
        #tag_name, page_obj, is_paginated, paginator = token.contents.split()
    #except ValueError:
        #raise template.TemplateSyntaxError(
            #"%r tag requires 3 arguments" % token.contents.split()[0]
        #)

    #return PagenavNode(page_obj, is_paginated, paginator)

#class PagenavNode(template.Node):
    #def __init__(self, page_obj, is_paginated, paginator):
        #self.page_obj = template.Variable(page_obj)
        #self.is_paginated = template.Variable(is_paginated)
        #self.paginator = template.Variable(paginator)

    #def render(self, context):
        #t = context.template.engine.get_template('students/pagination.html')
        #context['navigation'] = t.render(template.Context({
            #'page_obj': self.page_obj.resolve(context),
            #'is_paginated': self.is_paginated.resolve(context),
            #'paginator': self.paginator.resolve(context)}
        #))
        #return ''
log.py 文件源码 项目:gmail_scanner 作者: brandonhub 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __repr__(self):
        return "<GetAdminLog Node>"


问题


面经


文章

微信
公众号

扫码关注公众号