コード例 #1
0
ファイル: status.py プロジェクト: SeppPenner/tahoe-lafs
 def server_timings(self, req, tag):
     per_server = self._publish_status.timings.get("send_per_server")
     if not per_server:
         return tag()
     l = tags.ul()
     for server in sorted(per_server.keys(), key=lambda s: s.get_name()):
         times_s = ", ".join(
             [abbreviate_time(t) for t in per_server[server]])
         l(tags.li("[%s]: %s" % (server.get_name(), times_s)))
     return tags.li("Per-Server Response Times: ", l)
コード例 #2
0
ファイル: status.py プロジェクト: SeppPenner/tahoe-lafs
 def problems(self, req, tag):
     problems = self._publish_status.get_problems()
     if not problems:
         return tag()
     l = tags.ul()
     # XXX: is this exercised? I don't think PublishStatus.problems is
     # ever populated
     for peerid in sorted(problems.keys()):
         peerid_s = idlib.shortnodeid_b2a(peerid)
         l(tags.li("[%s]: %s" % (peerid_s, problems[peerid])))
     return tag(tags.li("Server Problems:", l))
コード例 #3
0
ファイル: fragments.py プロジェクト: mindpool/www.mindpool.io
 def getLinks(self, request):
     elements = []
     for text, url, type in self.sidebarLinks:
         if type == const.DIVIDER:
             continue
         if type == const.HEADER:
             elements.append(tags.li(text, class_="nav-header"))
             continue
         cssClass = ""
         if self.isInSubSection(request, url):
             cssClass = "active"
         elements.append(tags.li(tags.a(text, href=url), class_=cssClass))
     return elements
コード例 #4
0
ファイル: fragments.py プロジェクト: mindpool/www.mindpool.io
 def getLinks(self, request):
     elements = []
     for text, url, type in self.sidebarLinks:
         if type == const.DIVIDER:
             continue
         if type == const.HEADER:
             elements.append(
                 tags.li(text, class_="nav-header"))
             continue
         cssClass = ""
         if self.isInSubSection(request, url):
             cssClass = "active"
         elements.append(
             tags.li(tags.a(text, href=url), class_=cssClass))
     return elements
コード例 #5
0
 def stuff(self, request, tag):
     undoccedpublic = [o for o in self.system.orderedallobjects
                       if o.isVisible and not hasdocstring(o)]
     undoccedpublic.sort(key=lambda o:o.fullName())
     for o in undoccedpublic:
         tag(tags.li(o.kind, " - ", util.taglink(o)))
     return tag
コード例 #6
0
ファイル: summary.py プロジェクト: pombredanne/pydoctor
 def stuff(self, request, tag):
     undoccedpublic = [o for o in self.system.orderedallobjects
                       if o.isVisible and not hasdocstring(o)]
     undoccedpublic.sort(key=lambda o:o.fullName())
     for o in undoccedpublic:
         tag(tags.li(o.kind, " - ", taglink(o)))
     return tag
コード例 #7
0
ファイル: elements.py プロジェクト: oubiwann/tharsk
        def generateTabsAndContent(results):
            """
            results is a dictionary whose keys are normalized ASCII chars and
            whose values are the original (possible unicode) chars that map to
            the ASCII ones.
            """
            tabs = []
            contents = []
            for asciiLetter in sorted(results.keys()):
                if not asciiLetter:
                    continue
                for letter in sorted(results[asciiLetter]):
                    tab = tags.li(
                        tags.a(letter.upper(),
                               href="#l%s" % letter,
                               **{"data-toggle": "tab"}))
                    tabs.append(tab)
                    content = tags.div(tags.p("holding content"),
                                       class_="tab-pane",
                                       id="l%s" % letter)
                    contents.append(content)

            return tags.div(tags.ul(tabs, class_="nav nav-tabs"),
                            tags.div(contents, class_="tab-content"),
                            class_="tabbable tabs-left")
コード例 #8
0
    def names(self, request, tag):
        def link(obj: model.Documentable) -> Tag:
            # The "data-type" attribute helps doc2dash figure out what
            # category (class, method, etc.) an object belongs to.
            attributes = {}
            if obj.kind:
                attributes["data-type"] = epydoc2stan.format_kind(obj.kind)
            tag: Tag = tags.code(
                epydoc2stan.taglink(obj, NameIndexPage.filename), **attributes)
            return tag

        name2obs = {}
        for obj in self.initials[self.my_letter]:
            name2obs.setdefault(obj.name, []).append(obj)
        r = []
        for name in sorted(name2obs, key=lambda x: (x.lower(), x)):
            item = tag.clone()(name)
            obs = name2obs[name]
            if all(isPrivate(ob) for ob in obs):
                item(class_='private')
            if len(obs) == 1:
                item(' - ', link(obs[0]))
            else:
                ul = tags.ul()
                for ob in sorted(obs, key=_lckey):
                    subitem = tags.li(link(ob))
                    if isPrivate(ob):
                        subitem(class_='private')
                    ul(subitem)
                item(ul)
            r.append(item)
        return r
コード例 #9
0
ファイル: elements.py プロジェクト: oubiwann/tharsk
        def generateTabsAndContent(results):
            """
            results is a dictionary whose keys are normalized ASCII chars and
            whose values are the original (possible unicode) chars that map to
            the ASCII ones.
            """
            tabs = []
            contents = []
            for asciiLetter in sorted(results.keys()):
                if not asciiLetter:
                    continue
                for letter in sorted(results[asciiLetter]):
                    tab = tags.li(
                        tags.a(
                            letter.upper(),
                            href="#l%s" % letter,
                            **{"data-toggle": "tab"})
                        )
                    tabs.append(tab)
                    content = tags.div(
                        tags.p("holding content"),
                        class_="tab-pane",
                        id="l%s" % letter)
                    contents.append(content)

            return tags.div(
                tags.ul(tabs, class_="nav nav-tabs"),
                tags.div(contents, class_="tab-content"),
                class_="tabbable tabs-left")
コード例 #10
0
 def stuff(self, request, tag):
     undoccedpublic = [o for o in self.system.allobjects.values()
                       if o.isVisible and not hasdocstring(o)]
     undoccedpublic.sort(key=lambda o:o.fullName())
     for o in undoccedpublic:
         tag(tags.li(o.kind, " - ", tags.code(epydoc2stan.taglink(o, self.filename))))
     return tag
コード例 #11
0
ファイル: server.py プロジェクト: lamby/pydoctor
 def links(self, request, tag):
     ds = self.root.edits(self.ob)
     therange = range(len(ds))
     rev = therange[self.rev]
     ul = tags.ul()
     for i in therange:
         li = tags.li()
         if i:
             u = URLPath.fromRequest(request)
             u = u.sibling('diff')
             u.query = urllib.urlencode({
                 'ob': self.ob.fullName(),
                 'revA': i-1,
                 'revB': i,
                 })
             li(tags.a(href=str(u))("(diff)"))
         else:
             li("(diff)")
         li(" - ")
         if i == len(ds) - 1:
             label = "Latest"
         else:
             label = str(i)
         if i == rev:
             li(label)
         else:
             u = URLPath.fromRequest(request)
             u.query = urllib.urlencode({
                 'rev': str(i),
                 'ob': self.ob.fullName(),
                 })
             li(tags.a(href=str(u))(label))
         li(' - ' + ds[i].user + '/' + ds[i].time)
         ul(li)
     return tag(ul)
コード例 #12
0
ファイル: pubtahoe.py プロジェクト: habnabit/pubtahoe
 def _showDirectory(self, request, dirinfo):
     children = dirinfo[1]['children']
     body = tags.ul(*[
         tags.li(tags.a(name + ('/' if info[0] == 'dirnode' else ''),
                        href='/' + info[1]['ro_uri']))
         for name, info in children.iteritems()
     ])
     renderElement(request, body)
コード例 #13
0
ファイル: web.py プロジェクト: alucas/bravo
 def plugin(self, request, tag):
     plugins = []
     for name in self.plugins.keys():
         plugins.append(
             tags.li(
                 tags.a(name.title(),
                        href='%s/%s' % (self.factory.name, name))))
     return tag(tags.h2("Plugins"), tags.ul(*plugins))
コード例 #14
0
ファイル: status.py プロジェクト: SeppPenner/tahoe-lafs
 def problems(self, req, tag):
     problems = self._retrieve_status.get_problems()
     if not problems:
         return ""
     ul = tags.ul()
     for peerid in sorted(problems.keys()):
         peerid_s = idlib.shortnodeid_b2a(peerid)
         ul(tags.li("[%s]: %s" % (peerid_s, problems[peerid])))
     return tag("Server Problems:", ul)
コード例 #15
0
ファイル: status.py プロジェクト: SeppPenner/tahoe-lafs
 def problems(self, req, tag):
     problems = self._update_status.problems
     if not problems:
         return tag
     l = tags.ul()
     for peerid in sorted(problems.keys()):
         peerid_s = idlib.shortnodeid_b2a(peerid)
         l(tags.li("[%s]: %s" % (peerid_s, problems[peerid])))
     return tag("Server Problems:", l)
コード例 #16
0
ファイル: pubtahoe.py プロジェクト: nrr-deprecated/pubtahoe
 def _showDirectory(self, request, dirinfo):
     children = dirinfo[1]['children']
     body = tags.ul(*[
         tags.li(
             tags.a(name + ('/' if info[0] == 'dirnode' else ''),
                    href='/' + info[1]['ro_uri']))
         for name, info in children.iteritems()
     ])
     renderElement(request, body)
コード例 #17
0
ファイル: root.py プロジェクト: rpatterson/tahoe-lafs
    def _describe_connection_status(self, cs):
        """Return a dict containing some connection stats."""
        others = cs.non_connected_statuses

        if cs.connected:
            summary = cs.summary
            if others:
                hints = "\n".join([
                    "* %s: %s\n" % (which, others[which])
                    for which in sorted(others)
                ])
                details = "Other hints:\n" + hints
            else:
                details = "(no other hints)"
        else:
            details = tags.ul()
            for which in sorted(others):
                details(tags.li("%s: %s" % (which, others[which])))
            summary = [cs.summary, details]

        connected = "yes" if cs.connected else "no"
        connected_alt = self._connectedalts[connected]

        since = cs.last_connection_time

        if since is not None:
            service_connection_status_rel_time = render_time_delta(
                since, self._now_fn())
            service_connection_status_abs_time = render_time_attr(since)
        else:
            service_connection_status_rel_time = "N/A"
            service_connection_status_abs_time = "N/A"

        last_received_data_time = cs.last_received_time

        if last_received_data_time is not None:
            last_received_data_abs_time = render_time_attr(
                last_received_data_time)
            last_received_data_rel_time = render_time_delta(
                last_received_data_time, self._now_fn())
        else:
            last_received_data_abs_time = "N/A"
            last_received_data_rel_time = "N/A"

        return {
            "summary": summary,
            "details": details,
            "service_connection_status": connected,
            "service_connection_status_alt": connected_alt,
            "service_connection_status_abs_time":
            service_connection_status_abs_time,
            "service_connection_status_rel_time":
            service_connection_status_rel_time,
            "last_received_data_abs_time": last_received_data_abs_time,
            "last_received_data_rel_time": last_received_data_rel_time,
        }
コード例 #18
0
ファイル: elements.py プロジェクト: oubiwann/tharsk
 def dictionaries(self, request, tag):
     """
     """
     elements = []
     for dictionary in const.dictionaries:
         name = utils.getDictionaryName(dictionary)
         url = const.urls["dictionary"].replace(
             const.urlParams["dictionary"], dictionary)
         elements.append(tags.li(tags.a(name, href=url)))
     return tag(elements)
コード例 #19
0
 def getDropdown(self, title, url, cssClass):
     elements = []
     if title == "About":
         links = urls.aboutDropDown
     for text, url, type in links:
         if type == const.DIVIDER:
             element = tags.li(class_="divider")
         elif type == const.HEADER:
             element = tags.li(text, class_="nav-header")
         else:
             element = tags.li(tags.a(text, href=url))
         elements.append(element)
     return tags.li(tags.a(title,
                           tags.b(class_="caret"),
                           href="#",
                           class_="dropdown-toggle",
                           **{"data-toggle": "dropdown"}),
                    tags.ul(elements, class_="dropdown-menu"),
                    class_=cssClass)
コード例 #20
0
 def getDropdown(self, title, url, cssClass):
     elements = []
     if title == "About":
         links = urls.aboutDropDown
     for text, url, type in links:
         if type == const.DIVIDER:
             element = tags.li(class_="divider")
         elif type == const.HEADER:
             element = tags.li(text, class_="nav-header")
         else:
             element = tags.li(tags.a(text, href=url))
         elements.append(element)
     return tags.li(
         tags.a(
             title, tags.b(class_="caret"),
             href="#", class_="dropdown-toggle",
             **{"data-toggle": "dropdown"}),
         tags.ul(elements, class_="dropdown-menu"),
         class_=cssClass)
コード例 #21
0
ファイル: status.py プロジェクト: eevee/mamayo
    def render_GET(self, request):
        applications = []
        for app in self.registry.applications.values():
            link = tags.a(tags.tt(app.name), ' at ', tags.tt(app.path.path),
                          href=app.name)
            applications.append(tags.li(link))

        body = tags.body(
            tags.p('Here are your applications:'),
            tags.ul(*applications))
        return renderElement(request, body)
コード例 #22
0
ファイル: elements.py プロジェクト: oubiwann/tharsk
 def dictionaries(self, request, tag):
     """
     """
     elements = []
     for dictionary in const.dictionaries:
         name = utils.getDictionaryName(dictionary)
         url = const.urls["dictionary"].replace(
             const.urlParams["dictionary"], dictionary)
         elements.append(
             tags.li(tags.a(name, href=url)))
     return tag(elements)
コード例 #23
0
ファイル: status.py プロジェクト: SeppPenner/tahoe-lafs
 def server_timings(self, req, tag):
     per_server = self._update_status.timings.get("per_server")
     if not per_server:
         return tag("")
     l = tags.ul()
     for server in sorted(per_server.keys(), key=lambda s: s.get_name()):
         times = []
         for op, started, t in per_server[server]:
             #times.append("%s/%.4fs/%s/%s" % (op,
             #                              started,
             #                              self.render_time(None, started - self.update_status.get_started()),
             #                              self.render_time(None,t)))
             if op == "query":
                 times.append(abbreviate_time(t))
             elif op == "late":
                 times.append("late(" + abbreviate_time(t) + ")")
             else:
                 times.append("privkey(" + abbreviate_time(t) + ")")
         times_s = ", ".join(times)
         l(tags.li("[%s]: %s" % (server.get_name(), times_s)))
     return tags.li("Per-Server Response Times: ", l)
コード例 #24
0
ファイル: elements.py プロジェクト: oubiwann/tharsk
 def navLinks(self, request, tag):
     """
     """
     currentPath = request.path
     links = const.topNavLinks
     elements = []
     for text, url in links:
         cssClass = ""
         if url == currentPath:
             cssClass = "active"
         elements.append(tags.li(tags.a(text, href=url), class_=cssClass), )
     return tag(elements)
コード例 #25
0
ファイル: summary.py プロジェクト: tristanlatr/pydoctor
 def stuff(self, request: object, tag: Tag) -> Tag:
     undoccedpublic = [o for o in self.system.allobjects.values()
                       if o.isVisible and not hasdocstring(o)]
     undoccedpublic.sort(key=lambda o:o.fullName())
     for o in undoccedpublic:
         kind = o.kind
         assert kind is not None  # 'kind is None' makes the object invisible
         tag(tags.li(
             epydoc2stan.format_kind(kind), " - ",
             tags.code(epydoc2stan.taglink(o, self.filename))
             ))
     return tag
コード例 #26
0
ファイル: web.py プロジェクト: gwylim/bravo
    def main(self, request, tag):
        retval = []
        for automaton in factory.automatons:
            title = tags.h2(automaton.name)
            stats = []

            # Discover tracked information.
            if hasattr(automaton, "tracked"):
                t = automaton.tracked
                if isinstance(t, dict):
                    l = sum(len(i) for i in t.values())
                else:
                    l = len(t)
                stats.append(tags.li("Currently tracking %d blocks" % l))

            if hasattr(automaton, "step"):
                stats.append(tags.li("Currently processing every %f seconds" %
                    automaton.step))

            retval.append(tags.div(title, tags.ul(stats)))
        return tags.div(*retval)
コード例 #27
0
ファイル: info.py プロジェクト: tahoe-lafs/tahoe-lafs
 def raw_link(self, req, tag):
     node = self.original
     if IDirectoryNode.providedBy(node):
         node = node._node
     elif IFileNode.providedBy(node):
         pass
     else:
         return ""
     root = self.get_root(req)
     quoted_uri = urlquote(node.get_uri())
     text_plain_url = "%s/file/%s/@@named=/raw.txt" % (root, quoted_uri)
     return T.li("Raw data as ", T.a("text/plain", href=text_plain_url))
コード例 #28
0
def moduleSummary(modorpack):
    r = tags.li(util.taglink(modorpack), ' - ', epydoc2stan.doc2stan(modorpack, summary=True)[0])
    if not isinstance(modorpack, model.Package):
        return r
    contents = [m for m in modorpack.orderedcontents
                if m.isVisible and m.name != '__init__']
    if not contents:
        return r
    ul = tags.ul()
    for m in sorted(contents, key=lambda m:m.fullName()):
        ul(moduleSummary(m))
    return r(ul)
コード例 #29
0
ファイル: summary.py プロジェクト: pombredanne/pydoctor
def moduleSummary(modorpack):
    r = tags.li(taglink(modorpack), ' - ', epydoc2stan.doc2stan(modorpack, summary=True)[0])
    if not isinstance(modorpack, model.Package):
        return r
    contents = [m for m in modorpack.orderedcontents
                if m.isVisible and m.name != '__init__']
    if not contents:
        return r
    ul = tags.ul()
    for m in sorted(contents, key=lambda m:m.fullName()):
        ul(moduleSummary(m))
    return r(ul)
コード例 #30
0
ファイル: status.py プロジェクト: eevee/mamayo
    def render_GET(self, request):
        applications = []
        for app in self.registry.applications.values():
            link = tags.a(tags.tt(app.name),
                          ' at ',
                          tags.tt(app.path.path),
                          href=app.name)
            applications.append(tags.li(link))

        body = tags.body(tags.p('Here are your applications:'),
                         tags.ul(*applications))
        return renderElement(request, body)
コード例 #31
0
ファイル: web.py プロジェクト: gr8firedragon/bravo
 def service(self, request, tag):
     l = []
     services = []
     for name, service in self.services.iteritems():
         factory = service.args[1]
         if isinstance(factory, BravoFactory):
             services.append(self.bravofactory(request, tags.div, factory))
         else:
             l.append(
                 tags.li("%s (%s)" % (name, self.services[name].__class__)))
     ul = tags.ul(*l)
     div = tags.div(*services)
     return tag(ul, div)
コード例 #32
0
 def getLinks(self, request):
     elements = []
     for text, url, type in self.navLinks:
         cssClass = ""
         if self.isInSection(request, url):
             cssClass = "active"
         if type == const.DROPDOWN:
             cssClass += " dropdown"
             element = self.getDropdown(text, url, cssClass)
         else:
             element = tags.li(tags.a(text, href=url), class_=cssClass)
         elements.append(element)
     return elements
コード例 #33
0
ファイル: test_plating.py プロジェクト: vadfabi/zenchmarks
    def test_render_list(self):
        """
        The C{:list} renderer suffix will render the slot named by the renderer
        as a list, filling each slot.
        """
        @page.routed(self.app.route("/"),
                     tags.ul(tags.li(slot("item"), render="subplating:list")))
        def rsrc(request):
            return {"subplating": [1, 2, 3]}

        request, written = self.get(b"/")
        self.assertIn(b'<ul><li>1</li><li>2</li><li>3</li></ul>', written)
        self.assertIn(b'<title>default title unchanged</title>', written)
コード例 #34
0
 def getLinks(self, request):
     elements = []
     for text, url, type in self.navLinks:
         cssClass = ""
         if self.isInSection(request, url):
             cssClass = "active"
         if type == const.DROPDOWN:
             cssClass += " dropdown"
             element = self.getDropdown(text, url, cssClass)
         else:
             element = tags.li(tags.a(text, href=url), class_=cssClass)
         elements.append(element)
     return elements
コード例 #35
0
ファイル: test_plating.py プロジェクト: glasnt/klein
 def test_render_list(self):
     """
     The C{:list} renderer suffix will render the slot named by the renderer
     as a list, filling each slot.
     """
     @page.routed(self.app.route("/"),
                  tags.ul(tags.li(slot("item"),
                                  render="subplating:list")))
     def rsrc(request):
         return {"subplating": [1, 2, 3]}
     request, written = self.get(b"/")
     self.assertIn(b'<ul><li>1</li><li>2</li><li>3</li></ul>', written)
     self.assertIn(b'<title>default title unchanged</title>', written)
コード例 #36
0
ファイル: web.py プロジェクト: matejcik/bravo
 def service(self, request, tag):
     l = []
     services = []
     for name, service in self.services.iteritems():
         factory = service.args[1]
         if isinstance(factory, BravoFactory):
             services.append(self.bravofactory(request, tags.div, factory))
         else:
             l.append(tags.li("%s (%s)" %
                 (name, self.services[name].__class__)))
     ul = tags.ul(*l)
     div = tags.div(*services)
     return tag(ul, div)
コード例 #37
0
ファイル: status.py プロジェクト: SeppPenner/tahoe-lafs
 def sharemap(self, req, tag):
     servermap = self._publish_status.get_servermap()
     if servermap is None:
         return tag("None")
     l = tags.ul()
     sharemap = servermap.make_sharemap()
     for shnum in sorted(sharemap.keys()):
         l(
             tags.li(
                 "%d -> Placed on " % shnum, ", ".join([
                     "[%s]" % server.get_name()
                     for server in sharemap[shnum]
                 ])))
     return tag("Sharemap:", l)
コード例 #38
0
ファイル: elements.py プロジェクト: oubiwann/tharsk
 def navLinks(self, request, tag):
     """
     """
     currentPath = request.path
     links = const.topNavLinks
     elements = []
     for text, url in links:
         cssClass = ""
         if url == currentPath:
             cssClass = "active"
         elements.append(
             tags.li(tags.a(text, href=url), class_=cssClass),
             )
     return tag(elements)
コード例 #39
0
def subclassesFrom(hostsystem, cls, anchors):
    r = tags.li()
    name = cls.fullName()
    if name not in anchors:
        r(tags.a(name=name))
        anchors.add(name)
    r(util.taglink(cls), ' - ', epydoc2stan.doc2stan(cls, summary=True)[0])
    scs = [sc for sc in cls.subclasses if sc.system is hostsystem and ' ' not in sc.fullName()
           and sc.isVisible]
    if len(scs) > 0:
        ul = tags.ul()
        for sc in sorted(scs, key=_lckey):
            ul(subclassesFrom(hostsystem, sc, anchors))
        r(ul)
    return r
コード例 #40
0
ファイル: summary.py プロジェクト: pombredanne/pydoctor
def subclassesFrom(hostsystem, cls, anchors):
    r = tags.li()
    name = cls.fullName()
    if name not in anchors:
        r(tags.a(name=name))
        anchors.add(name)
    r(taglink(cls), ' - ', epydoc2stan.doc2stan(cls, summary=True)[0])
    scs = [sc for sc in cls.subclasses if sc.system is hostsystem and ' ' not in sc.fullName()
           and sc.isVisible]
    if len(scs) > 0:
        ul = tags.ul()
        for sc in sorted(scs, key=_lckey):
            ul(subclassesFrom(hostsystem, sc, anchors))
        r(ul)
    return r
コード例 #41
0
ファイル: summary.py プロジェクト: pombredanne/pydoctor
 def stuff(self, request, tag):
     t = tag
     anchors = set()
     for b, o in findRootClasses(self.system):
         if isinstance(o, model.Class):
             t(subclassesFrom(self.system, o, anchors))
         else:
             item = tags.li(tags.code(b))
             if o:
                 ul = tags.ul()
                 for sc in sorted(o, key=_lckey):
                     ul(subclassesFrom(self.system, sc, anchors))
                 item(ul)
             t(item)
     return t
コード例 #42
0
 def names(self, request, tag):
     name2obs = {}
     for obj in self.initials[self.my_letter]:
         name2obs.setdefault(obj.name, []).append(obj)
     r = []
     for name in sorted(name2obs, key=lambda x: (x.lower(), x)):
         obs = name2obs[name]
         if len(obs) == 1:
             r.append(tag.clone()(name, ' - ', util.taglink(obs[0])))
         else:
             ul = tags.ul()
             for ob in sorted(obs, key=_lckey):
                 ul(tags.li(util.taglink(ob)))
             r.append(tag.clone()(name, ul))
     return r
コード例 #43
0
ファイル: root.py プロジェクト: sumonst21/tahoe-lafs
    def services(self, req, tag):
        ul = tags.ul()
        try:
            ss = self._client.getServiceNamed("storage")
            stats = ss.get_stats()
            if stats["storage_server.accepting_immutable_shares"]:
                msg = "accepting new shares"
            else:
                msg = "not accepting new shares (read-only)"
            available = stats.get("storage_server.disk_avail")
            if available is not None:
                msg += ", %s available" % abbreviate_size(available)
            ul(tags.li(tags.a("Storage Server", href="storage"), ": ", msg))
        except KeyError:
            ul(tags.li("Not running storage server"))

        if self._client.helper:
            stats = self._client.helper.get_stats()
            active_uploads = stats["chk_upload_helper.active_uploads"]
            ul(tags.li("Helper: %d active uploads" % (active_uploads,)))
        else:
            ul(tags.li("Not running helper"))

        return tag(ul)
コード例 #44
0
 def stuff(self, request, tag):
     t = tag
     anchors = set()
     for b, o in findRootClasses(self.system):
         if isinstance(o, model.Class):
             t(subclassesFrom(self.system, o, anchors))
         else:
             item = tags.li(tags.code(b))
             if o:
                 ul = tags.ul()
                 for sc in sorted(o, key=_lckey):
                     ul(subclassesFrom(self.system, sc, anchors))
                 item(ul)
             t(item)
     return t
コード例 #45
0
ファイル: summary.py プロジェクト: pombredanne/pydoctor
 def names(self, request, tag):
     name2obs = {}
     for obj in self.initials[self.my_letter]:
         name2obs.setdefault(obj.name, []).append(obj)
     r = []
     for name in sorted(name2obs, key=lambda x:(x.lower(), x)):
         obs = name2obs[name]
         if len(obs) == 1:
             r.append(tag.clone()(name, ' - ', taglink(obs[0])))
         else:
             ul = tags.ul()
             for ob in sorted(obs, key=_lckey):
                 ul(tags.li(taglink(ob)))
             r.append(tag.clone()(name, ul))
     return r
コード例 #46
0
def moduleSummary(modorpack, page_url):
    r = tags.li(tags.code(epydoc2stan.taglink(modorpack, page_url)), ' - ',
                epydoc2stan.format_summary(modorpack))
    if modorpack.isPrivate:
        r(class_='private')
    if not isinstance(modorpack, model.Package):
        return r
    contents = [
        m for m in modorpack.contents.values()
        if m.isVisible and m.name != '__init__'
    ]
    if not contents:
        return r
    ul = tags.ul()
    for m in sorted(contents, key=lambda m: m.fullName()):
        ul(moduleSummary(m, page_url))
    return r(ul)
コード例 #47
0
ファイル: web.py プロジェクト: KingPsychopath/bravo
 def status(self, request, tag):
     world = self.factory.world
     l = []
     total = 0 + len(world._cache._dirty) + len(world._pending_chunks)
     l.append(tags.li("Total chunks: %d" % total))
     l.append(tags.li("Clean chunks: %d" % 0))
     l.append(tags.li("Dirty chunks: %d" % len(world._cache._dirty)))
     l.append(tags.li("Chunks being generated: %d" %
                      len(world._pending_chunks)))
     if world._cache._perm:
         l.append(tags.li("Permanent cache: enabled, %d chunks" %
                          len(world._cache._perm)))
     else:
         l.append(tags.li("Permanent cache: disabled"))
     status = tags.ul(*l)
     return tag(tags.h2("Status"), status)
コード例 #48
0
ファイル: web.py プロジェクト: matejcik/bravo
 def world(self, request, tag, world):
     l = []
     total = (len(world.chunk_cache) + len(world.dirty_chunk_cache) +
         len(world._pending_chunks))
     l.append(tags.li("Total chunks: %d" % total))
     l.append(tags.li("Clean chunks: %d" % len(world.chunk_cache)))
     l.append(tags.li("Dirty chunks: %d" % len(world.dirty_chunk_cache)))
     l.append(tags.li("Chunks being generated: %d" %
         len(world._pending_chunks)))
     if world.permanent_cache:
         l.append(tags.li("Permanent cache: enabled, %d chunks" %
             len(world.permanent_cache)))
     else:
         l.append(tags.li("Permanent cache: disabled"))
     status = tags.ul(*l)
     return tag(tags.h3("World status"), status)
コード例 #49
0
ファイル: server.py プロジェクト: chevah/pydoctor
 def preview(self, request, tag):
     docstring = parse_str(self.docstring)
     stan, errors = epydoc2stan.doc2stan(
         self.ob, docstring=docstring)
     if self.isPreview or errors:
         if errors:
             #print stan, errors
             #assert isinstance(stan, tags.pre)
             [text] = stan.children
             lines = text.replace('\r\n', '\n').split('\n')
             line2err = {}
             for err in errors:
                 if isinstance(err, str):
                     ln = None
                 else:
                     ln = err.linenum()
                 line2err.setdefault(ln, []).append(err)
             w = len(str(len(lines)))
             for i, line in enumerate(lines):
                 i += 1
                 cls = "preview"
                 if i in line2err:
                     cls += " error"
                 tag(tags.pre(class_=cls)("%*s"%(w, i), ' ', line))
                 for err in line2err.get(i, []):
                     tag(tags.p(class_="errormessage")(err.descr()))
             i += 1
             for err in line2err.get(i, []):
                 tag(tags.p(class_="errormessage")(err.descr()))
             items = []
             for err in line2err.get(None, []):
                 items.append(tags.li(str(err)))
             if items:
                 tag(tags.ul(items))
         else:
             tag = tag(stan)
         return tag(tags.h2("Edit"))
     else:
         return ()
コード例 #50
0
ファイル: web.py プロジェクト: matejcik/bravo
 def bravofactory(self, request, tag, factory):
     g = (tags.li(username) for username in factory.protocols)
     users = tags.div(tags.h3("Users"), tags.ul(*g))
     world = self.world(request, tags.div, factory.world)
     return tag(tags.h2("Bravo world %s" % factory.name), users, world)
コード例 #51
0
ファイル: web.py プロジェクト: RedKrieg/bravo
 def plugin(self, request, tag):
     plugins = []
     for name in self.plugins.keys():
         plugins.append(tags.li(tags.a(name.title(),
             href='%s/%s' % (self.factory.name, name))))
     return tag(tags.h2("Plugins"), tags.ul(*plugins))
コード例 #52
0
ファイル: html.py プロジェクト: glasnt/klein
app = Klein()

myStyle = Plating(
    tags=tags.html(
        tags.head(tags.title(slot("pageTitle"))),
        tags.body(tags.h1(slot("pageTitle"), Class="titleHeading"),
                  tags.div(slot(Plating.CONTENT)))
    ),
    defaults={"pageTitle": "Places & Foods"}
)

@myStyle.routed(
    app.route("/"),
    tags.div(
        tags.h2("Sample Places:"),
        tags.ul([tags.li(tags.a(href=["/places/", place])(place))
                 for place in ["new york", "san francisco", "shanghai"]]),
        tags.h2("Sample Foods:"),
        tags.ul([tags.li(tags.a(href=["/foods/", food])(food))
                 for food in ["hamburgers", "cheeseburgers", "hot dogs"]]),
    ))
def root(request):
    return {}

@myStyle.routed(app.route("/foods/<food>"),
              tags.table(border="2", style="color: blue")(
                  tags.tr(tags.td("Name:"), tags.td(slot("name"))),
                  tags.tr(tags.td("Deliciousness:"),
                          tags.td(slot("rating"), " stars")),
                  tags.tr(tags.td("Carbs:"),
                          tags.td(slot("carbohydrates")))))
コード例 #53
0
ファイル: web.py プロジェクト: RedKrieg/bravo
 def user(self, request, tag):
     users = (tags.li(username) for username in self.factory.protocols)
     return tag(tags.h2("Users"), tags.ul(*users))
コード例 #54
0
ファイル: web.py プロジェクト: RedKrieg/bravo
 def world(self, request, tag):
     worlds = []
     for name in self.worlds.keys():
         worlds.append(tags.li(tags.a(name.title(), href=name)))
     return tag(tags.h2("Worlds"), tags.ul(*worlds))
コード例 #55
0
ファイル: web.py プロジェクト: RedKrieg/bravo
 def service(self, request, tag):
     services = []
     for name, factory in self.services.iteritems():
         services.append(tags.li("%s (%s)" % (name, factory.__class__)))
     return tag(tags.h2("Services"), tags.ul(*services))