Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 68196bb

Browse files
committed
PEP 8 fixes.
1 parent 93380cd commit 68196bb

1 file changed

Lines changed: 30 additions & 24 deletions

File tree

nbconvert.py

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@ def rst_directive(directive, text=''):
3737
# Converters for parts of a cell.
3838
figures_counter = 1
3939

40+
4041
class ConversionException(Exception):
4142
pass
4243

44+
4345
class Converter(object):
4446
default_encoding = 'utf-8'
47+
4548
def __init__(self, fname):
4649
self.fname = fname
4750

@@ -50,10 +53,10 @@ def extension(self):
5053
raise ConversionException("""extension must be defined in Converter
5154
subclass""")
5255

53-
def dispatch(self,cell_type):
56+
def dispatch(self, cell_type):
5457
"""return cell_type dependent render method, for example render_code
5558
"""
56-
return getattr(self, 'render_'+cell_type, unknown_cell)
59+
return getattr(self, 'render_' + cell_type, unknown_cell)
5760

5861
def convert(self):
5962
lines = []
@@ -74,7 +77,7 @@ def read(self):
7477
with open(self.fname) as f:
7578
self.nb = nbformat.read(f, 'json')
7679

77-
def save(self,fname=None, encoding=None):
80+
def save(self, fname=None, encoding=None):
7881
"read and parse notebook into self.nb"
7982
if fname is None:
8083
fname = os.path.splitext(self.fname)[0] + '.' + self.extension
@@ -84,35 +87,37 @@ def save(self,fname=None, encoding=None):
8487
f.write(self.output.encode(encoding))
8588
return fname
8689

87-
def render_heading(self,cell):
88-
raise NotImplementedError
90+
def render_heading(self, cell):
91+
raise NotImplementedError
92+
93+
def render_code(self, cell):
94+
raise NotImplementedError
8995

90-
def render_code(self,cell):
91-
raise NotImplementedError
96+
def render_markdown(self, cell):
97+
raise NotImplementedError
9298

93-
def render_markdown(self,cell):
94-
raise NotImplementedError
99+
def render_pyout(self, cell):
100+
raise NotImplementedError
95101

96-
def render_pyout(self,cell):
97-
raise NotImplementedError
102+
def render_display_data(self, cell):
103+
raise NotImplementedError
98104

99-
def render_display_data(self,cell):
100-
raise NotImplementedError
105+
def render_stream(self, cell):
106+
raise NotImplementedError
101107

102-
def render_stream(self,cell):
103-
raise NotImplementedError
104108

105109
class ConverterRST(Converter):
106110
extension = 'rst'
107-
def render_heading(self,cell):
111+
112+
def render_heading(self, cell):
108113
"""convert a heading cell to rst
109114
110115
Returns list."""
111-
heading_level = {1:'=', 2:'-', 3:'`', 4:'\'', 5:'.',6:'~'}
116+
heading_level = {1: '=', 2: '-', 3: '`', 4: '\'', 5: '.', 6: '~'}
112117
marker = heading_level[cell.level]
113-
return ['{0}\n{1}\n'.format(cell.source, marker*len(cell.source))]
118+
return ['{0}\n{1}\n'.format(cell.source, marker * len(cell.source))]
114119

115-
def render_code(self,cell):
120+
def render_code(self, cell):
116121
"""Convert a code cell to rst
117122
118123
Returns list."""
@@ -129,13 +134,13 @@ def render_code(self,cell):
129134

130135
return lines
131136

132-
def render_markdown(self,cell):
137+
def render_markdown(self, cell):
133138
"""convert a markdown cell to rst
134139
135140
Returns list."""
136141
return [cell.source]
137142

138-
def render_pyout(self,output):
143+
def render_pyout(self, output):
139144
"""convert pyout part of a code cell to rst
140145
141146
Returns list."""
@@ -151,7 +156,7 @@ def render_pyout(self,output):
151156

152157
return lines
153158

154-
def render_display_data(self,output):
159+
def render_display_data(self, output):
155160
"""convert display data from the output of a code cell to rst.
156161
157162
Returns list.
@@ -171,7 +176,7 @@ def render_display_data(self,output):
171176

172177
return lines
173178

174-
def render_stream(self,output):
179+
def render_stream(self, output):
175180
"""convert stream part of a code cell to rst
176181
177182
Returns list."""
@@ -183,6 +188,7 @@ def render_stream(self,output):
183188

184189
return lines
185190

191+
186192
def rst2simplehtml(fname):
187193
"""Convert a rst file to simplified html suitable for blogger.
188194
@@ -228,7 +234,7 @@ def rst2simplehtml(fname):
228234
break
229235
f.write(line)
230236
f.write('\n')
231-
237+
232238
return newfname
233239

234240

0 commit comments

Comments
 (0)