forked from opengridcc/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot.py
40 lines (27 loc) · 949 Bytes
/
plot.py
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
35
36
37
38
39
40
import os
class Plot(object):
def __init__(self, title, description, content=None):
self.title = title
self.description = description
self._content = None
self.set_content(content)
def set_content(self, content):
self._content = content
def get_content(self):
return self._content
def has_content(self):
return self._content is not None
def is_html(self):
return isinstance(self, Html)
def is_figure(self):
return isinstance(self, Figure)
class Figure(Plot):
def __init__(self, *args, **kwargs):
super(Figure, self).__init__(*args, **kwargs)
class Html(Plot):
def __init__(self, *args, **kwargs):
super(Html, self).__init__(*args, **kwargs)
def set_content(self, path):
if os.path.exists(path):
with open(path, "r") as html_graph:
self._content = html_graph.read()