当前位置: 首页>>代码示例>>Python>>正文


Python E.th方法代码示例

本文整理汇总了Python中lxml.html.builder.E.th方法的典型用法代码示例。如果您正苦于以下问题:Python E.th方法的具体用法?Python E.th怎么用?Python E.th使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lxml.html.builder.E的用法示例。


在下文中一共展示了E.th方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _gen_header

# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import th [as 别名]
    def _gen_header(self, ctx, cls, name, parent):
        with parent.element('thead'):
            with parent.element('tr'):
                th_attrs = {}
                if self.field_name_attr is not None:
                    th_attrs[self.field_name_attr] = name

                # fti is none when the type inside Array is not a ComplexModel.
                if issubclass(cls, ComplexModelBase):
                    fti = cls.get_flat_type_info(cls)
                    if self.field_name_attr is None:
                        for k, v in fti.items():
                            if getattr(v.Attributes, 'exc_html', None):
                                continue
                            header_name = self.translate(v, ctx.locale, k)
                            parent.write(E.th(header_name, **th_attrs))
                    else:
                        for k, v in fti.items():
                            if getattr(v.Attributes, 'exc_html', None):
                                continue
                            th_attrs[self.field_name_attr] = k
                            header_name = self.translate(v, ctx.locale, k)
                            parent.write(E.th(header_name, **th_attrs))

                else:
                    if self.field_name_attr is not None:
                        th_attrs[self.field_name_attr] = name
                    header_name = self.translate(cls, ctx.locale, name)
                    parent.write(E.th(header_name, **th_attrs))

                self.extend_header_row(ctx, cls, name, parent)
开发者ID:lanwan,项目名称:spyne,代码行数:33,代码来源:table.py

示例2: _gen_header

# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import th [as 别名]
    def _gen_header(self, ctx, cls, name, parent):
        logger.debug("Generate header for %r", cls)

        with parent.element('thead'):
            with parent.element('tr'):
                th_attrs = {}
                if self.field_name_attr is not None:
                    th_attrs[self.field_name_attr] = name

                if issubclass(cls, ComplexModelBase):
                    fti = cls.get_flat_type_info(cls)
                    if self.field_name_attr is None:
                        for k, v in fti.items():
                            attr = get_cls_attrs(self, v)
                            if attr.exc:
                                continue
                            header_name = self.trc(v, ctx.locale, k)
                            parent.write(E.th(header_name, **th_attrs))
                    else:
                        for k, v in fti.items():
                            attr = get_cls_attrs(self, v)
                            if attr.exc:
                                continue
                            th_attrs[self.field_name_attr] = k
                            header_name = self.trc(v, ctx.locale, k)
                            parent.write(E.th(header_name, **th_attrs))

                else:
                    if self.field_name_attr is not None:
                        th_attrs[self.field_name_attr] = name
                    header_name = self.trc(cls, ctx.locale, name)
                    parent.write(E.th(header_name, **th_attrs))

                self.extend_header_row(ctx, cls, name, parent)
开发者ID:DmitriyMoseev,项目名称:spyne,代码行数:36,代码来源:table.py

示例3: build_title_content

# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import th [as 别名]
    def build_title_content(self):
        content = E.table(
            E.tr(
                E.th(self.T('Time')),
                E.th(self.T('Message')),
                E.th(self.T('Count'))
            )
        )

        for message in self._messages:
            message_dict = dict(message.data_iter)

            row = E.tr(
                E.td(self.handler.locale.format_date(message.datetime),
                    rowspan=str(len(message_dict)))
            )

            for key, count in sorted(message_dict.items()):
                row.extend([E.td(to_hex(key)), E.td(str(count))])
                content.append(row)
                row = E.tr()

        self.elements.content.append(content)

        if self._pager_next:
            self.elements.content.append(
                E.a(self.T('Older'), href='?before=' + str(self._pager_next))
            )

        self.add_footer()
开发者ID:chfoo,项目名称:wuff,代码行数:32,代码来源:textshow.py

示例4: _gen_thead

# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import th [as 别名]
    def _gen_thead(self, ctx, cls, name, parent):
        logger.debug("Generate header for %r", cls)

        with parent.element('thead'):
            with parent.element('tr'):
                if issubclass(cls, ComplexModelBase):
                    fti = self.sort_fields(cls)
                    for k, v in fti:
                        attr = self.get_cls_attrs(v)
                        if attr.exc:
                            continue

                        th_attrs = {}
                        if self.field_name_attr is not None:
                            th_attrs[self.field_name_attr] = k
                        if attr.hidden:
                            th_attrs['style'] = 'display:None'

                        header_name = self.trc(v, ctx.locale, k)
                        parent.write(E.th(header_name, **th_attrs))

                    m = cls.Attributes.methods
                    if m is not None and len(m) > 0:
                        parent.write(E.th())

                else:
                    th_attrs = {}
                    if self.field_name_attr is not None:
                        th_attrs[self.field_name_attr] = name
                    header_name = self.trc(cls, ctx.locale, name)
                    parent.write(E.th(header_name, **th_attrs))

                self.extend_header_row(ctx, cls, parent, name)
开发者ID:mahdi-b,项目名称:spyne,代码行数:35,代码来源:table.py

示例5: _gen_thead

# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import th [as 别名]
    def _gen_thead(self, ctx, cls, parent, name):
        logger.debug("Generate header for %r", cls)

        with parent.element('thead'):
            with parent.element('tr'):
                if issubclass(cls, ComplexModelBase):
                    fti = self.sort_fields(cls)
                    for k, v in fti:
                        cls_attr = self.get_cls_attrs(v)
                        if cls_attr.exc:
                            continue

                        th_attrs = {}
                        self.add_field_attrs(th_attrs, k, cls)

                        if cls_attr.hidden:
                            self.add_style(th_attrs, 'display:None')

                        header_name = self.trc(v, ctx.locale, k)
                        parent.write(E.th(header_name, **th_attrs))

                    m = cls.Attributes.methods
                    if m is not None and len(m) > 0:
                        th_attrs = {'class': 'mrpc-cell'}
                        parent.write(E.th(**th_attrs))

                else:
                    th_attrs = {}
                    self.add_field_attrs(th_attrs, name, cls)

                    header_name = self.trc(cls, ctx.locale, name)

                    parent.write(E.th(header_name, **th_attrs))

                self.extend_header_row(ctx, cls, parent, name)
开发者ID:knoxsp,项目名称:spyne,代码行数:37,代码来源:column.py

示例6: serialize_complex_model

# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import th [as 别名]
    def serialize_complex_model(self, cls, value):
        sti = None
        fti = cls.get_flat_type_info(cls)

        first_child = iter(fti.values()).next()
        if len(fti) == 1:
            fti = first_child.get_flat_type_info(first_child)
            first_child = iter(fti.values()).next()
            if len(fti) == 1 and first_child.Attributes.max_occurs > 1:
                if issubclass(first_child, ComplexModelBase):
                    sti = first_child.get_simple_type_info(first_child)
                value = value[0]
            else:
                raise Exception("Can only serialize Array(...) types")
        else:
            raise Exception("Can only serialize single Array(...) return types")

        header_row = E.tr()
        class_name = first_child.get_type_name()
        if sti is None:
            header_row.append(E.th(class_name))
        else:
            if self.field_name_attr is None:
                for k, v in sti.items():
                    header_row.append(E.th(k))
            else:
                for k, v in sti.items():
                    header_row.append(E.th(k,
                                        **{self.field_name_attr: k}))

        yield header_row

        if sti is None:
            if self.field_name_attr is None:
                for val in value:
                    yield E.tr(E.td(first_child.to_string(val)), )
            else:
                for val in value:
                    yield E.tr(E.td(first_child.to_string(val)),
                                           **{self.field_name_attr: class_name})

        else:
            for val in value:
                row = E.tr()
                print val
                for k, v in sti.items():
                    subvalue = val
                    for p in v.path:
                        subvalue = getattr(subvalue, p, "`%s`" % k)
                    if self.field_name_attr is None:
                        row.append(E.td(v.type.to_string(subvalue)))
                    else:
                        row.append(E.td(v.type.to_string(subvalue),
                                                   **{self.field_name_attr: k}))
                yield row
开发者ID:surajbarkale,项目名称:rpclib,代码行数:57,代码来源:html.py

示例7: array_to_parent

# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import th [as 别名]
    def array_to_parent(self, ctx, cls, inst, parent, name, **kwargs):
        with parent.element('div'):
            if issubclass(cls, ComplexModelBase):
                ret = super(HtmlRowTable, self).array_to_parent(
                                         ctx, cls, inst, parent, name, **kwargs)
                if isgenerator(ret):
                    try:
                        while True:
                            sv2 = (yield)
                            ret.send(sv2)
                    except Break as b:
                        try:
                            ret.throw(b)
                        except StopIteration:
                            pass
            else:
                table_attrib = {}
                if self.table_name_attr:
                    table_attrib = {self.table_name_attr: name}
                if self.table_width is not None:
                    table_attrib['width'] = self.table_width

                with parent.element('table', table_attrib):
                    tr_attrib = {}
                    if self.row_class is not None:
                        tr_attrib['class'] = self.row_class
                    with parent.element('tr', tr_attrib):
                        if self.header:
                            parent.write(E.th(self.trc(cls, ctx.locale,
                                                          cls.get_type_name())))
                        td_attrs = {}

                        if self.cell_class is not None:
                            self.add_html_attr('class', td_attrs,
                                                                self.cell_class)

                        self.add_field_attrs(td_attrs, name, cls)

                        cls_attrs = self.get_cls_attrs(cls)

                        if cls_attrs.hidden:
                            self.add_style(td_attrs, 'display:None')

                        with parent.element('td', td_attrs):
                            with parent.element('table'):
                                ret = super(HtmlRowTable, self) \
                                    .array_to_parent(ctx, cls, inst, parent,
                                                                 name, **kwargs)
                                if isgenerator(ret):
                                    try:
                                        while True:
                                            sv2 = (yield)
                                            ret.send(sv2)
                                    except Break as b:
                                        try:
                                            ret.throw(b)
                                        except StopIteration:
                                            pass
开发者ID:ashleysommer,项目名称:spyne,代码行数:60,代码来源:row.py

示例8: complex_model_to_parent

# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import th [as 别名]
    def complex_model_to_parent(self, ctx, cls, inst, parent, name,
                                                      from_arr=False, **kwargs):
        attrib = {}
        if self.table_name_attr is not None:
            attrib[self.table_name_attr] = cls.get_type_name()

        with parent.element('table', attrib, nsmap=NSMAP):
            with parent.element('tbody'):
                for k, v in cls.get_flat_type_info(cls).items():
                    try:
                        sub_value = getattr(inst, k, None)
                    except: # to guard against e.g. SQLAlchemy throwing NoSuchColumnError
                        sub_value = None

                    sub_name = v.Attributes.sub_name
                    if sub_name is None:
                        sub_name = k

                    if sub_value is None and cls.Attributes.min_occurs == 0:
                        self.null_to_parent(ctx, cls, sub_value, parent,
                                                             sub_name, **kwargs)
                        continue

                    tr_attrib = {}
                    if self.row_class is not None:
                        tr_attrib['class'] = self.row_class
                    with parent.element('tr', tr_attrib):
                        th_attrib = {}
                        if self.header_cell_class is not None:
                            th_attrib['class'] = self.header_cell_class
                        if self.field_name_attr is not None:
                            th_attrib[self.field_name_attr] = sub_name
                        if self.produce_header:
                            parent.write(E.th(
                                self.trc(v, ctx.locale, sub_name),
                                **th_attrib
                            ))

                        td_attrib = {}
                        if self.cell_class is not None:
                            td_attrib['class'] = self.cell_class
                        if self.field_name_attr is not None:
                            td_attrib[self.field_name_attr] = sub_name

                        with parent.element('td', td_attrib):
                            ret = self.to_parent(ctx, v, sub_value, parent,
                                                            sub_name, **kwargs)
                            if isgenerator(ret):
                                try:
                                    while True:
                                        sv2 = (yield)
                                        ret.send(sv2)
                                except Break as b:
                                    try:
                                        ret.throw(b)
                                    except StopIteration:
                                        pass
开发者ID:DmitriyMoseev,项目名称:spyne,代码行数:59,代码来源:table.py

示例9: model_base_to_parent

# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import th [as 别名]
    def model_base_to_parent(self, ctx, cls, inst, parent, name, **kwargs):
        retval = E.tr()
        attr = {}
        if self.field_name_attr is not None:
            attr = {self.field_name_attr: name}

        if self.produce_header:
            retval.append(E.th(self.translate(cls, ctx.locale, name), **attr))

        retval.append(E.td(self.to_string(cls, inst), **attr))
        parent.write(retval)
开发者ID:jpunwin,项目名称:spyne,代码行数:13,代码来源:table.py

示例10: array_to_parent

# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import th [as 别名]
    def array_to_parent(self, ctx, cls, inst, parent, name, **kwargs):
        with parent.element('div', nsmap=NSMAP):
            if issubclass(cls, ComplexModelBase):
                ret = super(HtmlRowTable, self).array_to_parent(
                                         ctx, cls, inst, parent, name, **kwargs)
                if isgenerator(ret):
                    try:
                        while True:
                            sv2 = (yield)
                            ret.send(sv2)
                    except Break as b:
                        try:
                            ret.throw(b)
                        except StopIteration:
                            pass
            else:
                table_attrib = {}
                if self.table_name_attr:
                    table_attrib = {self.table_name_attr: name}

                with parent.element('table', table_attrib, nsmap=NSMAP):
                    tr_attrib = {}
                    if self.row_class is not None:
                        tr_attrib['class'] = self.row_class
                    with parent.element('tr', tr_attrib):
                        if self.produce_header:
                            parent.write(E.th(self.trc(cls, ctx.locale,
                                                          cls.get_type_name())))
                        td_attrib = {}
                        if self.cell_class is not None:
                            td_attrib['class'] = self.cell_class
                        with parent.element('td', td_attrib):
                            with parent.element('table'):
                                ret = super(HtmlRowTable, self) \
                                    .array_to_parent(ctx, cls, inst, parent,
                                                                 name, **kwargs)
                                if isgenerator(ret):
                                    try:
                                        while True:
                                            sv2 = (yield)
                                            ret.send(sv2)
                                    except Break as b:
                                        try:
                                            ret.throw(b)
                                        except StopIteration:
                                            pass
开发者ID:DmitriyMoseev,项目名称:spyne,代码行数:48,代码来源:table.py

示例11: complex_model_to_parent

# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import th [as 别名]
    def complex_model_to_parent(self, ctx, cls, inst, parent, name, 
                                                    tr_child=False, **kwargs):
        attrs = {}
        if tr_child is False:
            ret = self._get_members(ctx, cls, inst, parent, 
                                                tr_child=True, **kwargs)
            if isgenerator(ret):
                try:
                    while True:
                        sv2 = (yield)
                        ret.send(sv2)
                except Break as b:
                    try:
                        ret.throw(b)
                    except StopIteration:
                        pass

        else:
            if self.table_name_attr is not None:
                attrs[self.table_name_attr] = name

            with parent.element('tr', attrs):
                if self.produce_header:
                    parent.write(E.th(self.translate(cls, ctx.locale, name),
                                                **{self.field_name_attr: name}))
                with parent.element('td', attrs):
                    ret = self.subserialize(ctx, cls, inst, parent, None, name)
                    if isgenerator(ret):
                        try:
                            while True:
                                sv2 = (yield)
                                ret.send(sv2)
                        except Break as b:
                            try:
                                ret.throw(b)
                            except StopIteration:
                                pass
开发者ID:jpunwin,项目名称:spyne,代码行数:39,代码来源:table.py

示例12: serialize_complex_model

# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import th [as 别名]
    def serialize_complex_model(self, cls, value, locale):
        sti = None
        fti = cls.get_flat_type_info(cls)
        is_array = False

        if len(fti) == 1:
            first_child, = fti.values()

            try:
                fti = first_child.get_flat_type_info(first_child)
            except AttributeError:
                raise NotImplementedError("Can only serialize complex return types")

            first_child_2 = iter(fti.values()).next()

            if len(fti) == 1 and first_child_2.Attributes.max_occurs > 1:
                if issubclass(first_child_2, ComplexModelBase):
                    sti = first_child_2.get_simple_type_info(first_child_2)
                is_array = True

            else:
                if issubclass(first_child, ComplexModelBase):
                    sti = first_child.get_simple_type_info(first_child)

            value = value[0]

        else:
            raise NotImplementedError("Can only serialize single return types")

        tr = {}
        if self.row_class is not None:
            tr['class'] = self.row_class

        td = {}
        if self.cell_class is not None:
            td['class'] = self.cell_class

        th = {}
        if self.header_cell_class is not None:
            th['class'] = self.header_cell_class

        class_name = first_child.get_type_name()
        if sti is None:
            if self.field_name_attr is not None:
                td[self.field_name_attr] = class_name

            if is_array:
                for val in value:
                    yield E.tr(E.td(first_child_2.to_string(val), **td), **tr)
            else:
                yield E.tr(E.td(first_child_2.to_string(value), **td), **tr)

        else:
            for k, v in sti.items():
                row = E.tr(**tr)
                subvalue = value
                for p in v.path:
                    subvalue = getattr(subvalue, p, None)
                    if subvalue is None:
                        break

                if subvalue is None:
                    if v.type.Attributes.min_occurs == 0:
                        continue
                    else:
                        subvalue = ""
                else:
                    subvalue = _subvalue_to_html(v, subvalue)

                if self.produce_header:
                    header_text = translate(v.type, locale, k)
                    if self.field_name_attr is None:
                        row.append(E.th(header_text, **th))
                    else:
                        th[self.field_name_attr] = k
                        row.append(E.th(header_text, **th))

                if self.field_name_attr is None:
                    row.append(E.td(subvalue, **td))

                else:
                    td[self.field_name_attr] = k
                    row.append(E.td(subvalue, **td))

                yield row
开发者ID:drowolath,项目名称:spyne,代码行数:87,代码来源:html.py

示例13: serialize_complex_model

# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import th [as 别名]
    def serialize_complex_model(self, cls, value, locale):
        fti = cls.get_flat_type_info(cls)
        if cls.Attributes._wrapper and not issubclass(cls, Array):
            if len(fti) > 1:
                raise NotImplementedError("Can only serialize one array at a time")
            cls, = cls._type_info.values()
            value, = value

        fti = cls.get_flat_type_info(cls)
        first_child = iter(fti.values()).next()
        if not issubclass(cls, Array):
            raise NotImplementedError("Can only serialize Array(...) types")

        sti = None
        if issubclass(first_child, ComplexModelBase):
            sti = first_child.get_simple_type_info(first_child)

        # Here, sti can be None when the return type does not have _type_info
        # attribute
        tr = {}
        if self.row_class is not None:
            tr['class'] = self.row_class

        td = {}
        if self.cell_class is not None:
            td['class'] = self.cell_class

        class_name = first_child.get_type_name()
        if self.produce_header:
            header_row = E.tr(**tr)

            th = {}
            if self.header_cell_class is not None:
                th['class'] = self.header_cell_class

            # sti is none when the type inside Array is not a ComplexModel.
            if sti is None:
                header_row.append(E.th(class_name, **th))

            else:
                if self.field_name_attr is None:
                    for k, v in sti.items():
                        header_name = translate(v.type, locale, k)
                        header_row.append(E.th(header_name, **th))

                else:
                    for k, v in sti.items():
                        th[self.field_name_attr] = k
                        header_name = translate(v.type, locale, k)
                        header_row.append(E.th(header_name, **th))

            yield header_row

        if value is None:
            raise StopIteration()

        if sti is None:
            if self.field_name_attr is None:
                for val in value:
                    yield E.tr(E.td(self.to_string(first_child, val),**td),**tr)

            else:
                for val in value:
                    td[self.field_name_attr] = class_name
                    yield E.tr(E.td(self.to_string(first_child, val),**td),**tr)

        else:
            for val in value:
                row = E.tr()
                for k, v in sti.items():
                    subvalue = val
                    for p in v.path:
                        subvalue = getattr(subvalue, p, None)

                    if subvalue is None:
                        subvalue = ""
                    else:
                        subvalue = _subvalue_to_html(self, v, subvalue)

                    if self.field_name_attr is None:
                        row.append(E.td(subvalue, **td))
                    else:
                        td[self.field_name_attr] = k
                        row.append(E.td(subvalue, **td))

                yield row
开发者ID:harshil07,项目名称:spyne,代码行数:88,代码来源:html.py

示例14: subserialize

# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import th [as 别名]
    def subserialize(self, ctx, cls, inst, parent, ns=None, name=None):
        attrs = {}
        if self.table_name_attr is not None:
            attrs[self.table_name_attr] = name

        locale = ctx.locale
        with parent.element('table', attrs):
            fti = None
            if issubclass(cls, ComplexModelBase):
                fti = cls.get_flat_type_info(cls)
            if self.produce_header:
                with parent.element('thead'):
                    header_row = E.tr()

                    th = {}
                    if self.header_cell_class is not None:
                        th['class'] = self.header_cell_class

                    # fti is none when the type inside Array is not a ComplexModel.
                    if fti is None:
                        if self.field_name_attr is not None:
                            th[self.field_name_attr] = name
                        header_name = self.translate(cls, ctx.locale, name)
                        header_row.append(E.th(header_name, **th))

                    else:
                        if self.field_name_attr is None:
                            for k, v in fti.items():
                                header_name = self.translate(v, ctx.locale, k)
                                header_row.append(E.th(header_name, **th))

                        else:
                            for k, v in fti.items():
                                th[self.field_name_attr] = k
                                header_name = self.translate(v, ctx.locale, k)
                                header_row.append(E.th(header_name, **th))

                    parent.write(header_row)

            with parent.element('tbody'):
                if cls.Attributes.max_occurs > 1:
                    ret = self.array_to_parent(ctx, cls, inst, parent, name)
                    if isgenerator(ret):
                        try:
                            while True:
                                y = (yield)
                                ret.send(y)
                        except Break as b:
                            try:
                                ret.throw(b)
                            except StopIteration:
                                pass

                else:
                    with parent.element('tr'):
                        ret = self.to_parent(ctx, cls, inst, parent, name)
                        if isgenerator(ret):
                            try:
                                while True:
                                    y = (yield)
                                    ret.send(y)
                            except Break as b:
                                try:
                                    ret.throw(b)
                                except StopIteration:
                                    pass
开发者ID:jpunwin,项目名称:spyne,代码行数:68,代码来源:table.py

示例15: complex_model_to_parent

# 需要导入模块: from lxml.html.builder import E [as 别名]
# 或者: from lxml.html.builder.E import th [as 别名]
    def complex_model_to_parent(self, ctx, cls, inst, parent, name,
                                                      from_arr=False, **kwargs):
        attrib = {}
        if self.table_name_attr is not None:
            attrib[self.table_name_attr] = cls.get_type_name()
        if self.table_width is not None:
            attrib['width'] = self.table_width

        with parent.element('table', attrib):
            with parent.element('tbody'):
                for k, v in self.sort_fields(cls):
                    sub_attrs = self.get_cls_attrs(v)
                    if sub_attrs.exc:
                        logger.debug("\tExclude table cell %r type %r for %r",
                                                                      k, v, cls)
                        continue
                    try:
                        sub_value = getattr(inst, k, None)
                    except:  # e.g. SQLAlchemy could throw NoSuchColumnError
                        sub_value = None

                    sub_name = v.Attributes.sub_name
                    if sub_name is None:
                        sub_name = k

                    tr_attrs = {}
                    if self.row_class is not None:
                        self.add_html_attr('class', tr_attrs, self.row_class)

                    with parent.element('tr', tr_attrs):
                        th_attrs = {}

                        if self.header_cell_class is not None:
                            self.add_html_attr('class', th_attrs,
                                                         self.header_cell_class)

                        self.add_field_attrs(th_attrs, sub_name, v)

                        if sub_attrs.hidden:
                            self.add_style(th_attrs, 'display:None')

                        if self.header:
                            parent.write(E.th(
                                self.trc(v, ctx.locale, sub_name),
                                **th_attrs
                            ))

                        td_attrs = {}
                        if self.cell_class is not None:
                            self.add_html_attr('class', td_attrs,
                                                                self.cell_class)

                        self.add_field_attrs(td_attrs, sub_name, v)

                        if sub_attrs.hidden:
                            self.add_style(td_attrs, 'display:None')

                        with parent.element('td', td_attrs):
                            ret = self.to_parent(ctx, v, sub_value, parent,
                                                             sub_name, **kwargs)
                            if isgenerator(ret):
                                try:
                                    while True:
                                        sv2 = (yield)
                                        ret.send(sv2)
                                except Break as b:
                                    try:
                                        ret.throw(b)
                                    except StopIteration:
                                        pass
开发者ID:ashleysommer,项目名称:spyne,代码行数:72,代码来源:row.py


注:本文中的lxml.html.builder.E.th方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。