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


Python E.b方法代码示例

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


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

示例1: show_state

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import b [as 别名]
 def show_state():
     l.append(sep)
     #~ l.append(E.b(unicode(state),style="vertical-align:middle;"))
     if state.button_text:
         l.append(E.b(u"{} {}".format(state.button_text, state)))
     else:
         l.append(E.b(str(state)))
开发者ID:lino-framework,项目名称:lino,代码行数:9,代码来源:model.py

示例2: about_html

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import b [as 别名]
    def about_html(cls):

        body = []

        body.append(settings.SITE.welcome_html())

        if settings.SITE.languages:
            body.append(E.p(str(_("Languages")) + ": " + ', '.join([
                lng.django_code for lng in settings.SITE.languages])))

        # print "20121112 startup_time", settings.SITE.startup_time.date()
        def dtfmt(dt):
            if isinstance(dt, float):
                dt = datetime.datetime.fromtimestamp(dt)
                # raise ValueError("Expected float, go %r" % dt)
            return str(_("%(date)s at %(time)s")) % dict(
                date=dd.fds(dt.date()),
                time=settings.SITE.strftime(dt.time()))

        value = settings.SITE.startup_time
        label = _("Server uptime")
        body.append(E.p(
            str(label), ' : ', E.b(dtfmt(value)),
            ' ({})'.format(settings.TIME_ZONE)))
        if settings.SITE.is_demo_site:
            s = str(_("This is a Lino demo site."))
            body.append(E.p(s))
        if settings.SITE.the_demo_date:
            s = _("We are running with simulated date set to {0}.").format(
                dd.fdf(settings.SITE.the_demo_date))
            body.append(E.p(s))
            
        body.append(E.p(str(_("Source timestamps:"))))
        items = []
        times = []
        packages = set(['lino', 'django', 'atelier'])
        for p in settings.SITE.installed_plugins:
            packages.add(p.app_name.split('.')[0])
        for src in packages:
            label = src
            value = codetime('%s.*' % src)
            if value is not None:
                times.append((label, value))

        times.sort(key=lambda x: x[1])
        for label, value in times:
            items.append(E.li(str(label), ' : ', E.b(dtfmt(value))))
        body.append(E.ul(*items))
        return rt.html_text(E.div(*body))
开发者ID:lino-framework,项目名称:lino,代码行数:51,代码来源:models.py

示例3: body_subject_to_elems

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import b [as 别名]
def body_subject_to_elems(ar, title, description):
    """
    Convert the given `title` and `description` to a list of HTML
    elements.

    Used by :mod:`lino.modlib.notify` and by :mod:`lino_xl.lib.sales`
    """
    if description:
        elems = [E.p(E.b(title), E.br())]
        elems += rich_text_to_elems(ar, description)
        
    else:
        elems = [E.b(title)]
        # return E.span(self.title)
    return elems
开发者ID:lino-framework,项目名称:lino,代码行数:17,代码来源:bleached.py

示例4: get_change_desc_html

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import b [as 别名]
 def get_change_desc_html(self, f, old, new):
     from lino.core.choicelists import ChoiceListField
     if isinstance(f, models.TextField):
         old = old or ''
         new = new or ''
         if False:
             diff = difflib.unified_diff(
                 old.splitlines(), new.splitlines(),
                 fromfile="before", tofile="after", lineterm='')
             txt = E.pre('\n'.join(diff))
         else:
             labels = {
                 '+': _("lines added"),
                 '-': _("lines removed"),
                 '?': _("modifications"),
                 ' ': _("lines changed")}
             diff = list(difflib.ndiff(
                 old.splitlines(), new.splitlines()))
             counters = {}
             for ln in diff:
                 if ln:
                     k = ln[0]
                     c = counters.get(k, 0)
                     counters[k] = c + 1
             txt = ', '.join([
                 "{0} {1}".format(n, labels[op])
                 for op, n in counters.items()])
         return E.li(
             E.b(str(f.verbose_name)), " : ", txt)
         
     if isinstance(f, models.DateTimeField):
         return
     if isinstance(f, models.ForeignKey):
         if old:
             old = f.remote_field.model.objects.get(pk=old)
         if new:
             new = f.remote_field.model.objects.get(pk=new)
     elif isinstance(f, ChoiceListField):
         if isinstance(old, six.string_types):
             old = f.choicelist.get_by_value(old)
         if isinstance(new, six.string_types):
             new = f.choicelist.get_by_value(new)
     else:
         old = obj2unicode(old)
         new = obj2unicode(new)
     return E.li(
         E.b(str(f.verbose_name)), " : ",
         u"{0} --> {1}".format(old, new))
开发者ID:lino-framework,项目名称:lino,代码行数:50,代码来源:diff.py

示例5: href_button

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import b [as 别名]
    def href_button(self, url, text, title=None, icon_name=None, **kw):
        """Returns an etree object of a ``<a href>`` tag to the given URL
        `url`.

        `url` is what goes into the `href` part. If `url` is `None`,
        then we return just a ``<b>`` tag.

        `text` is what goes between the ``<a>`` and the ``</a>``. This
        can be either a string or a tuple (or list) of strings (or
        etree elements).

        """
        # logger.info('20121002 href_button %s', unicode(text))
        if title:
            # Remember that Python 2.6 doesn't like if title is a Promise
            kw.update(title=str(title))
            #~ return xghtml.E.a(text,href=url,title=title)
        if not isinstance(text, (tuple, list)):
            text = (text,)
        text = forcetext(text)
        if url is None:
            return E.b(*text)

        kw.update(href=url)
        if icon_name is not None:
            src = settings.SITE.build_static_url(
                'images', 'mjames', icon_name + '.png')
            img = E.img(src=src, alt=icon_name)
            return E.a(img, **kw)
        else:
            return E.a(*text, **kw)
开发者ID:lino-framework,项目名称:lino,代码行数:33,代码来源:renderer.py

示例6: value2html

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import b [as 别名]
 def value2html(self, ar):
     txt = dd.format_currency(self.value, False, True)
     if self.item.is_heading():
         # return E.b(txt)
         return E.div(E.b(txt), align="right")
     # return txt
     return E.div(txt, align="right")
开发者ID:lino-framework,项目名称:xl,代码行数:9,代码来源:models.py

示例7: what

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import b [as 别名]
 def what(self, obj, ar):
     chunks = []
     if obj.name:
         chunks += [E.b(str(obj)), E.br()]
     chunks += sepjoin(obj.features.all())
     #~ if obj.url:
         #~ chunks += [E.br(),E.a(_("More"),href=obj.url)]
     return E.p(*chunks)
开发者ID:lino-framework,项目名称:xl,代码行数:10,代码来源:models.py

示例8: description

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import b [as 别名]
 def description(self, ar):
     if self.ref is None:
         s = self.get_designation()
     else:
         s = self.ref
         s = u' ' * (len(s)-1) + s
         s += " " + self.get_designation()
     if self.is_heading():
         s = E.b(s)
     return s
开发者ID:lino-framework,项目名称:lino,代码行数:12,代码来源:ref.py

示例9: question

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import b [as 别名]
    def question(self, obj, ar):
        if obj.question.number:
            txt = obj.question.NUMBERED_TITLE_FORMAT % (
                obj.question.number, obj.question.title)
        else:
            txt = obj.question.title

        attrs = {}
        if obj.question.details:
            attrs.update(title=obj.question.details)
        if obj.question.is_heading:
            txt = E.b(txt, **attrs)
        return ar.html_text(E.span(txt, **attrs))
开发者ID:lino-framework,项目名称:xl,代码行数:15,代码来源:models.py

示例10: get_rfc_description

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import b [as 别名]
 def get_rfc_description(self, ar):
     html = ''
     _ = gettext
     if self.description:
         # html += tostring(E.b(_("Description")))
         html += ar.parse_memo(self.description)
     if self.upgrade_notes:
         html += tostring(E.b(_("Resolution"))) + ": "
         html += ar.parse_memo(self.upgrade_notes)
     if self.duplicate_of_id:
         html += tostring(_("Duplicate of")) + " "
         html += tostring(self.duplicate_of.obj2href(ar))
     return html
开发者ID:khchine5,项目名称:xl,代码行数:15,代码来源:models.py

示例11: get_table_summary

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import b [as 别名]
    def get_table_summary(self, obj, ar):
        """Customized :meth:`summary view
        <lino.core.actors.Actor.get_table_summary>` for this table.

        """
        sar = self.request_from(ar, master_instance=obj)

        html = []
        states = {}
        for s, d in VoteStates.choices:
            states[s] = []

        u = ar.get_user()

        for o in sar:
            states[o.state].append(ar.obj2html(o, o.user.initials or str(o.user), title=o.state))
            if u == o.user:
                html.insert(0, E.span(
                    E.b(str(o.state)),
                    u" \u2192 ",
                    *join_elems([sar.action_button(ba, o) for ba in sar.actor.get_actions()
                                 if ba.action.show_in_workflow and
                                 sar.actor.get_row_permission(o, sar, o.state, ba) and
                                 isinstance(ba.action, dd.ChangeStateAction)],
                                " ")
                ))


        html.append(E.ul(
            *[E.li(*([str(s.text),  ": "] + join_elems(states[s], sep=", "))) for s, c in VoteStates.choices
              if states[s]
              ]
        ))
        # print(tostring(html))
        # items = [
        #     ar.obj2html(o, o.user.username or str(o.user))
        #     for o in rt.models.votes.Vote.objects.filter(
        #             votable=obj).order_by('-id')]
        # sar.get_user() == v.user
        sar = self.insert_action.request_from(sar)
        if sar.get_permission():
            # btn = sar.ar2button(None, _("Add voter"), icon_name=None)
            btn = sar.ar2button()
            # btn = sar.ar2button(None, u"⏍", icon_name=None)  # 23CD SQUARE FOOT
            # btn = sar.ar2button(None, u"⊞", icon_name=None) # 229e SQUARED PLUS
            
            html.append(E.div(btn))

            
        return ar.html_text(E.div(*html))
开发者ID:lino-framework,项目名称:xl,代码行数:52,代码来源:models.py

示例12: answer_buttons

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import b [as 别名]
    def answer_buttons(self, obj, ar):
        # assert isinstance(obj, Answer)
        cs = obj.question.get_choiceset()
        if cs is None:
            return ''

        elems = []
        pv = dict(question=obj.question)

        # ia = obj.response.toggle_choice
        sar = obj.response.toggle_choice.request_from(
            ar, is_on_main_actor=False)
        # print(20170731, sar.is_on_main_actor)
        if False:  # since 20170129
            ba = Responses.actions.toggle_choice
            if ba is None:
                raise Exception("No toggle_choice on {0}?".format(ar.actor))
            sar = ba.request_from(ar)

            # print("20150203 answer_buttons({0})".format(sar))

            # if the response is registered, just display the choice, no
            # toggle buttons since answer cannot be toggled:
            # 20151211
            sar.selected_rows = [obj.response]
            
        if not sar.get_permission():
            return str(obj)

        AnswerChoice = rt.models.polls.AnswerChoice
        for c in cs.choices.all():
            pv.update(choice=c)
            text = str(c)
            qs = AnswerChoice.objects.filter(
                response=obj.response, **pv)
            if qs.count() == 1:
                text = [E.b('[', text, ']')]
            elif qs.count() == 0:
                pass
            else:
                raise Exception(
                    "Oops: %s returned %d rows." % (qs.query, qs.count()))
            sar.set_action_param_values(**pv)
            e = sar.ar2button(obj.response, text, style="text-decoration:none")
            elems.append(e)
        return ar.html_text(E.span(*join_elems(elems)))
开发者ID:lino-framework,项目名称:xl,代码行数:48,代码来源:models.py

示例13: welcome_messages

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import b [as 别名]
def welcome_messages(ar):
    """Yield messages for the welcome page."""
    #todo show all users active sessions

    Session = rt.models.working.Session
    # Ticket = rt.models.tickets.Ticket
    # TicketStates = rt.models.tickets.TicketStates
    me = ar.get_user()

    # your open sessions (i.e. those you are busy with)
    qs = Session.objects.filter(end_time__isnull=True)
    working = {me:[E.b(six.text_type(_("You are busy with ")))]}
    if qs.count() == 0:
        return
    for ses in qs:
        if ses.user not in working:
            working[ses.user] = [ar.obj2html(ses.user),
                                 gettext(" is working on: ")]
        txt = six.text_type(ses.ticket)
        working[ses.user].append(
            ar.obj2html(ses.ticket, txt, title=getattr(ses.ticket,'summary',"") or
                                               getattr(ses.ticket,'name',"")))

        if ses.user == me:
            working[ses.user] += [
                ' (',
                ar.instance_action_button(
                    ses.end_session, EndTicketSession.label),
                ')']
        working[ses.user].append(', ')

    if len(working[me]) > 1:

        working[me][-1] = working[me][-1].replace(", ", ".")
        result = E.p(*working.pop(me))
    else:
        result = E.p()
        working.pop(me)
    for u, s in working.items():
        if len(result):
            result.append(E.br())
        s[-1] = s[-1].replace(", ", ".")
        result.append(E.span(*s))
    yield result
开发者ID:lino-framework,项目名称:xl,代码行数:46,代码来源:models.py

示例14: show_menu

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import b [as 别名]
    def show_menu(self, ar, mnu, level=1):
        """
        Render the given menu as an HTML element.
        Used for writing test cases.
        """
        if not isinstance(mnu, Menu):
            assert isinstance(mnu, MenuItem)
            if mnu.bound_action:
                sar = mnu.bound_action.actor.request(
                    action=mnu.bound_action,
                    user=ar.user, subst_user=ar.subst_user,
                    requesting_panel=ar.requesting_panel,
                    renderer=self, **mnu.params)
                # print("20170113", sar)
                url = sar.get_request_url()
            else:
                url = mnu.href
            assert mnu.label is not None
            if url is None:
                return E.p()  # spacer
            return E.li(E.a(str(mnu.label), href=url, tabindex="-1"))

        items = [self.show_menu(ar, mi, level + 1) for mi in mnu.items]
        #~ print 20120901, items
        if level == 1:
            return E.ul(*items, **{'class':'nav navbar-nav'})
        if mnu.label is None:
            raise Exception("%s has no label" % mnu)
        if level == 2:
            cl = 'dropdown'
            menu_title = E.a(
                str(mnu.label), E.b(' ', **{'class': "caret"}), href="#",
                data_toggle="dropdown", **{'class':'dropdown-toggle'})
        elif level == 3:
            menu_title = E.a(str(mnu.label), href="#")
            cl = 'dropdown-submenu'
        else:
            raise Exception("Menu with more than three levels")
        return E.li(
            menu_title,
            E.ul(*items, **{'class':'dropdown-menu'}),
            **{'class':cl})
开发者ID:lino-framework,项目名称:lino,代码行数:44,代码来源:renderer.py

示例15: eid_info

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import b [as 别名]
    def eid_info(self, ar):
        "Display some information about the eID card."
        attrs = {'class':"lino-info"}
        if ar is None:
            return E.div(**attrs)
        must_read = False
        elems = []
        if self.card_number:
            elems += ["%s %s (%s)" %
                      (ugettext("Card no."), self.card_number, self.card_type)]
            if self.card_issuer:
                elems.append(", %s %s" %
                             (ugettext("issued by"), self.card_issuer))
                #~ card_issuer = _("issued by"),
            if self.card_valid_until is not None:
                valid = ", %s %s %s %s" % (
                    ugettext("valid from"), dd.dtos(self.card_valid_from),
                    ugettext("until"), dd.dtos(self.card_valid_until))
                if self.card_valid_until < dd.today():
                    must_read = True
                    elems.append(E.b(valid))
                    elems.append(E.br())
                else:
                    elems.append(valid)

            else:
                must_read = True
        else:
            must_read = True
        if must_read:
            msg = _("Must read eID card!")
            if dd.plugins.beid:
                elems.append(ar.instance_action_button(
                    self.read_beid, msg, icon_name=None))
            else:
                elems.append(msg)
            # same red as in lino.css for .x-grid3-row-red td
            # ~ attrs.update(style="background-color:#FA7F7F; padding:3pt;")
            attrs['class'] = "lino-info-red"
        return E.div(*elems, **attrs)
开发者ID:khchine5,项目名称:xl,代码行数:42,代码来源:mixins.py


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