Example #1
0
 def print_message(self):
     message = markdown.markdown(
         MESSAGE.format(
             register_or_sign_in_url=
             f"<{self.owner.register_or_sign_in_url}>",
             retrieve_api_key_url=f"<{self.owner.retrieve_api_key_url}>",
         ))
     # We use Python's markdown instead of IPython's Markdown because
     # jupyter lab/colab/deepnotes all behave differently
     display(HTML(HTML_MESSAGE.format(message=message)))
Example #2
0
 def ask(self, p, method):
     message = f"Please enter a value for <span style='color: red;'>{p.get('title')}</span>"
     if "default" in p:
         message += f" or leave empty for the default value <span style='color: red;'>{p.get('default')}</span>"
     message += ", then press *ENTER*"
     if "example" in p:
         message += f" The value should look like  <span style='color: red;'>{p.get('example')}</span>"
     message = markdown.markdown(message)
     display(HTML(HTML_ASK.format(message=message)))
     return method(p.get("title") + ": ").strip()
Example #3
0
def make_map(path, bbox, **kwargs):

    center = (0, 0)
    zoom = 1

    if bbox is not None:
        center = (bbox.north + bbox.south) / 2, (bbox.east + bbox.west) / 2
        zoom = 1 / max((bbox.north - bbox.south) / 180,
                       (bbox.east - bbox.west) / 360)
        zoom = (2 * zoom + 88) / 27

    m = folium.Map(zoom_start=zoom, location=center)

    SVGOverlay(
        path=path,
        # bounds=[[85.051129, -180],[-85.051129, 180]],
        bounds=[[90, -180], [-90, 180]],
        # options=dict(opacity=0.6, autoZIndex=True),
    ).add_to(m)

    folium.plugins.Fullscreen(force_separate_button=True).add_to(m)
    NoScrollZoom().add_to(m)

    if bbox is not None:
        m.fit_bounds([[bbox.south, bbox.east], [bbox.north, bbox.west]])

    html = m._repr_html_()

    if guess_which_ipython()[0] == "deepnote":

        # For deepnote
        html = html.replace("width: 100%;height: 100%",
                            "width: 100%").replace("height: 100.0%;",
                                                   "height: 609px;")

    return HTML(html)
Example #4
0
 def ask_user_markdown(self) -> str:
     message = markdown.markdown(self.markdown_message)
     # We use Python's markdown instead of IPython's Markdown because
     # jupyter lab/colab/deepnotes all behave differently
     display(HTML(HTML_MESSAGE.format(message=message)))
     return getpass.getpass(self.prompt + ": ")