6
6
7
7
# File types
8
8
class Format (object ):
9
- """ Template for a specific file type; renders and
10
- writes out to file.
9
+ """Template for a specific file type; renders and
10
+ writes out to file.
11
11
12
- For text formats, simply override the templates
13
- below. For other formats, override `render`
14
- and `write`.
12
+ For text formats, simply override the templates
13
+ below. For other formats, override `render`
14
+ and `write`.
15
15
16
- `render` should return an object whose string
17
- representation is a fully valid document of
18
- that format.
16
+ `render` should return an object whose string
17
+ representation is a fully valid document of
18
+ that format.
19
19
"""
20
20
21
21
template = "{title}\n \n {sections}\n \n {docs_link}"
@@ -33,8 +33,8 @@ def __init__(self, checklist):
33
33
self .checklist = checklist
34
34
35
35
def render (self ):
36
- """ Uses the checklist and templates to render
37
- all of the components for this format.
36
+ """Uses the checklist and templates to render
37
+ all of the components for this format.
38
38
"""
39
39
rendered_sections = []
40
40
for section in self .checklist .sections :
@@ -60,14 +60,14 @@ def render(self):
60
60
sections = all_sections ,
61
61
docs_link = self .docs_link ,
62
62
badge = self .badge ,
63
- ) # noqa: E501
63
+ )
64
64
65
65
def write (self , filepath , overwrite = False ):
66
- """ Renders template and writes to `filepath`.
66
+ """Renders template and writes to `filepath`.
67
67
68
- If `overwrite=True`, write over anything at
69
- `filepath`. Else, if the file exists append to
70
- the end of file.
68
+ If `overwrite=True`, write over anything at
69
+ `filepath`. Else, if the file exists append to
70
+ the end of file.
71
71
"""
72
72
filepath = Path (filepath )
73
73
@@ -82,8 +82,7 @@ def write(self, filepath, overwrite=False):
82
82
83
83
84
84
class Markdown (Format ):
85
- """ Markdown template items
86
- """
85
+ """Markdown template items"""
87
86
88
87
template = "# {title}\n {badge}\n {sections}\n \n {docs_link}"
89
88
section_template = """## {title}
@@ -95,12 +94,11 @@ class Markdown(Format):
95
94
)
96
95
badge = """
97
96
[](http://deon.drivendata.org/)
98
- """ # noqa: E501
97
+ """
99
98
100
99
101
100
class Rst (Format ):
102
- """reStructuredText template items
103
- """
101
+ """reStructuredText template items"""
104
102
105
103
template = "{title}\n ============\n \n {badge}\n \n {sections}\n \n {docs_link}"
106
104
section_template = """{title}\n ---------\n \n {lines}"""
@@ -123,14 +121,13 @@ def __repr__(self):
123
121
124
122
125
123
class JupyterNotebook (Markdown ):
126
- """ Jupyter notebook template items
127
- """
124
+ """Jupyter notebook template items"""
128
125
129
126
append_delimiter = {"cell_type" : "markdown" , "metadata" : {}, "source" : ["-----\n " ]}
130
127
131
128
def render (self ):
132
- """ Creates json for a valid blank Jupyter notebook with a cell
133
- containing the rendered Markdown of the checklist.
129
+ """Creates json for a valid blank Jupyter notebook with a cell
130
+ containing the rendered Markdown of the checklist.
134
131
"""
135
132
text = super ().render ()
136
133
@@ -150,9 +147,9 @@ def render(self):
150
147
return JsonDict (blank_jupyter_notebook )
151
148
152
149
def write (self , filepath , overwrite = False ):
153
- """ If notebook does not exist (or `overwrite=True`), write new
154
- notebook with checklist. Otherwise append a cell with a
155
- horizontal rule and another cell with the checklist.
150
+ """If notebook does not exist (or `overwrite=True`), write new
151
+ notebook with checklist. Otherwise append a cell with a
152
+ horizontal rule and another cell with the checklist.
156
153
"""
157
154
nbdata = self .render ()
158
155
@@ -171,8 +168,7 @@ def write(self, filepath, overwrite=False):
171
168
172
169
173
170
class JupyterNotebookMulticell (JupyterNotebook ):
174
- """ Jupyter notebook multiple cell format
175
- """
171
+ """Jupyter notebook multiple cell format"""
176
172
177
173
def render (self ):
178
174
text = super (JupyterNotebook , self ).render ()
@@ -232,18 +228,18 @@ class Html(Format):
232
228
"""
233
229
234
230
def render (self ):
235
- """ Create a new blank HTML document with checklist as the body.
236
- Returned as a BeautifulSoup object.
231
+ """Create a new blank HTML document with checklist as the body.
232
+ Returned as a BeautifulSoup object.
237
233
"""
238
234
rendered_html = self .doc_template .format (text = super ().render ())
239
235
soup = BeautifulSoup (rendered_html , "html.parser" )
240
236
# string representation of soup is the raw html, so we can return it
241
237
return soup
242
238
243
239
def write (self , filepath , overwrite = False ):
244
- """ If html document does not exist (or `overwrite=True`), write new
245
- html file with checklist. Otherwise append checklist to the end of
246
- the body of the existing html file.
240
+ """If html document does not exist (or `overwrite=True`), write new
241
+ html file with checklist. Otherwise append checklist to the end of
242
+ the body of the existing html file.
247
243
"""
248
244
filepath = Path (filepath )
249
245
0 commit comments