forked from iloveitaly/python-starter-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole.py
More file actions
executable file
·34 lines (23 loc) · 849 Bytes
/
console.py
File metadata and controls
executable file
·34 lines (23 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env -S ipython -i
# Description: production REPL, not designed to be used locally. `./console.py` in production.
# ruff: noqa: F401, F821
# some common utilities that are a pain to reimplement
import json
import re
from urllib.request import urlopen
import ipython_playground
from typeid import TypeID
# helpful shortcuts
from app import log
from app.configuration.clerk import clerk
globals().update(ipython_playground.all_extras())
def read_data_url(url):
"""
Read a url with json, csv, etc and return the data.
Helpful for pulling external data for one-off scripts
"""
# convert start gist URLS to raw URLs
if re.match(r"https?://gist\.github\.com/", url):
url = url.replace("gist.github.com", "gist.githubusercontent.com") + "/raw"
return urlopen(url).read()
ipython_playground.output()