Example #1
0
    def _repr_html_(self):
        """Return a html representation of the cache .

        Returns
        -------
        str
            HTML status of the cache.
        """

        html = [css("table")]
        with self.new_connection() as db:
            for n in db.execute("SELECT * FROM cache"):
                n = dict(n)
                n["missing"] = not os.path.exists(n["path"])
                n["temporary"] = os.path.exists(
                    n["path"] + ".tmp") or os.path.exists(
                        n["path"] + ".tmp.download"
                    )  # TODO: decide how to handle temporary extension
                if n["size"] is None:
                    n["size"] = 0
                html.append("<table class='climetlab'>")
                html.append("<td><td colspan='2'>%s</td></tr>" % (n["path"], ))

                for k in [
                        x for x in n.keys() if x not in ("path", "owner_data")
                ]:
                    v = humanize.bytes(n[k]) if k == "size" else n[k]
                    html.append("<td><td>%s</td><td>%s</td></tr>" % (k, v))
                html.append("</table>")
                html.append("<br>")
        return "".join(html)
Example #2
0
 def _repr_html_(self):
     html = [css("table")]
     html.append("<table class='climetlab'>")
     for k, v in sorted(self._settings.items()):
         html.append("<tr><td>%s</td><td>%r</td><td>%r</td></td>" %
                     (k, v, SETTINGS_AND_HELP.get(k, (None, "..."))[0]))
     html.append("</table>")
     return "".join(html)
Example #3
0
 def _repr_html_(self):
     html = [css("table")]
     html.append("<table class='climetlab'>")
     for k, v in sorted(self._settings.items()):
         setting = SETTINGS_AND_HELP.get(k, None)
         default = setting.default if setting else ""
         html.append("<tr><td>%s</td><td>%r</td><td>%r</td></td>" %
                     (k, v, default))
     html.append("</table>")
     return "".join(html)
Example #4
0
    def _repr_html_(self):
        html = [
            css("table"),
            "<table class='climetlab'>",
            "<tr><td>Name:</td><td>%s</td></tr>" % self.name,
            "<tr><td>Collection:</td><td>%s</td></tr>" % self.kind,
            "<tr><td>Path:</td><td>%s</td></tr>" % self.path,
        ]

        html.append("<tr><td>Definition:</td><td><pre>%s</pre></td></tr>" %
                    (yaml.dump(self.data, default_flow_style=False), ))
        html.append("</table>")
        return "".join(html)
Example #5
0
    def _repr_html_(self):

        update_cache()

        html = [css("table")]
        with connection() as db:
            for n in db.execute("SELECT * FROM cache"):
                html.append("<table class='climetlab'>")
                html.append("<td><td colspan='2'>%s</td></tr>" % (n["path"], ))

                for k in [x for x in n.keys() if x != "path"]:
                    v = bytes_to_string(n[k]) if k == "size" else n[k]
                    html.append("<td><td>%s</td><td>%s</td></tr>" % (k, v))
                html.append("</table>")
                html.append("<br>")
        return "".join(html)
Example #6
0
    def _repr_html_(self):
        """Return a html representation of the cache .

        Returns
        -------
        str
            HTML status of the cache.
        """

        html = [css("table")]
        with self.connection as db:
            for n in db.execute("SELECT * FROM cache"):
                html.append("<table class='climetlab'>")
                html.append("<td><td colspan='2'>%s</td></tr>" % (n["path"],))

                for k in [x for x in n.keys() if x not in ("path", "owner_data")]:
                    v = bytes_to_string(n[k]) if k == "size" else n[k]
                    html.append("<td><td>%s</td><td>%s</td></tr>" % (k, v))
                html.append("</table>")
                html.append("<br>")
        return "".join(html)