##// END OF EJS Templates
pep8, third pass
Barry Wark -
Show More
@@ -227,19 +227,19 b' class IPythonCocoaController(NSObject, FrontEndBase):'
227 NSMakeRange(self.textView.textStorage().length(),
227 NSMakeRange(self.textView.textStorage().length(),
228 0))
228 0))
229
229
230 def currentBlock(self):
230 def current_block(self):
231 """The current block's text"""
231 """The current block's text"""
232
232
233 return self.textForRange(self.current_block_range())
233 return self.text_for_range(self.current_block_range())
234
234
235 def textForRange(self, textRange):
235 def text_for_range(self, textRange):
236 """textForRange"""
236 """text_for_range"""
237
237
238 ts = self.textView.textStorage()
238 ts = self.textView.textStorage()
239 return ts.string().substringWithRange_(textRange)
239 return ts.string().substringWithRange_(textRange)
240
240
241 def currentLine(self):
241 def current_line(self):
242 block = self.textForRange(self.current_block_range())
242 block = self.text_for_range(self.current_block_range())
243 block = block.split('\n')
243 block = block.split('\n')
244 return block[-1]
244 return block[-1]
245
245
@@ -288,8 +288,8 b' class IPythonCocoaController(NSObject, FrontEndBase):'
288 def current_indent_string(self):
288 def current_indent_string(self):
289 """returns string for indent or None if no indent"""
289 """returns string for indent or None if no indent"""
290
290
291 if(len(self.currentBlock()) > 0):
291 if(len(self.current_block()) > 0):
292 lines = self.currentBlock().split('\n')
292 lines = self.current_block().split('\n')
293 currentIndent = len(lines[-1]) - len(lines[-1])
293 currentIndent = len(lines[-1]) - len(lines[-1])
294 if(currentIndent == 0):
294 if(currentIndent == 0):
295 currentIndent = self.tabSpaces
295 currentIndent = self.tabSpaces
@@ -313,12 +313,12 b' class IPythonCocoaController(NSObject, FrontEndBase):'
313 if(selector == 'insertNewline:'):
313 if(selector == 'insertNewline:'):
314 indent = self.current_indent_string()
314 indent = self.current_indent_string()
315 if(indent):
315 if(indent):
316 line = indent + self.currentLine()
316 line = indent + self.current_line()
317 else:
317 else:
318 line = self.currentLine()
318 line = self.current_line()
319
319
320 if(self.is_complete(self.currentBlock())):
320 if(self.is_complete(self.current_block())):
321 self.execute(self.currentBlock(),
321 self.execute(self.current_block(),
322 blockID=self.currentBlockID)
322 blockID=self.currentBlockID)
323 self.start_new_block()
323 self.start_new_block()
324
324
@@ -327,7 +327,7 b' class IPythonCocoaController(NSObject, FrontEndBase):'
327 return False
327 return False
328
328
329 elif(selector == 'moveUp:'):
329 elif(selector == 'moveUp:'):
330 prevBlock = self.get_history_previous(self.currentBlock())
330 prevBlock = self.get_history_previous(self.current_block())
331 if(prevBlock != None):
331 if(prevBlock != None):
332 self.replace_current_block_with_string(textView, prevBlock)
332 self.replace_current_block_with_string(textView, prevBlock)
333 else:
333 else:
@@ -368,7 +368,7 b' class IPythonCocoaController(NSObject, FrontEndBase):'
368 return False # don't actually handle the delete
368 return False # don't actually handle the delete
369
369
370 elif(selector == 'insertTab:'):
370 elif(selector == 'insertTab:'):
371 if(len(self.currentLine().strip()) == 0): #only white space
371 if(len(self.current_line().strip()) == 0): #only white space
372 return False
372 return False
373 else:
373 else:
374 self.textView.complete_(self)
374 self.textView.complete_(self)
@@ -70,7 +70,15 b' class IFrontEnd(zi.Interface):'
70 """Subclass may override to update the input prompt for a block.
70 """Subclass may override to update the input prompt for a block.
71 Since this method will be called as a
71 Since this method will be called as a
72 twisted.internet.defer.Deferred's callback,
72 twisted.internet.defer.Deferred's callback,
73 implementations should return result when finished."""
73 implementations should return result when finished.
74
75 NB: result is a failure if the execute returned a failre.
76 To get the blockID, you should do something like::
77 if(isinstance(result, twisted.python.failure.Failure)):
78 blockID = result.blockID
79 else:
80 blockID = result['blockID']
81 """
74
82
75 pass
83 pass
76
84
@@ -311,7 +319,7 b' class FrontEndBase(object):'
311 twisted.internet.defer.Deferred's callback, implementations should
319 twisted.internet.defer.Deferred's callback, implementations should
312 return result when finished.
320 return result when finished.
313
321
314 NP: result is a failure if the execute returned a failre.
322 NB: result is a failure if the execute returned a failre.
315 To get the blockID, you should do something like::
323 To get the blockID, you should do something like::
316 if(isinstance(result, twisted.python.failure.Failure)):
324 if(isinstance(result, twisted.python.failure.Failure)):
317 blockID = result.blockID
325 blockID = result.blockID
General Comments 0
You need to be logged in to leave comments. Login now