Skip to content

Commit 7a2c6e9

Browse files
committed
[scripts/odmlview] Add fetch stylesheet function
1 parent 1ac0498 commit 7a2c6e9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

odml/scripts/odml_view.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,26 @@
1616
import http.server as hs
1717
import socketserver
1818
import sys
19+
import urllib.request as urllib2
1920
import webbrowser
2021

2122
from docopt import docopt
2223

2324
PORT = 8000
25+
REPOSITORY = "https://templates.g-node.org/_resources/"
26+
STYLESHEET = "odmlTerms.xsl"
27+
28+
29+
def fetch_stylesheet():
30+
try:
31+
data = urllib2.urlopen("%s%s" % (REPOSITORY, STYLESHEET)).read()
32+
data = data.decode("utf-8")
33+
except Exception as e:
34+
print("failed loading '%s%s': %s" % (REPOSITORY, STYLESHEET, e))
35+
return
36+
37+
with open(STYLESHEET, "w") as fp:
38+
fp.write(str(data))
2439

2540

2641
def run(port=PORT):

0 commit comments

Comments
 (0)