Changeset 650
- Timestamp:
- 07/23/05 10:17:25 (3 years ago)
- Files:
-
- nbshell/trunk/IPythonLog.py (modified) (2 diffs)
- nbshell/trunk/Main.py (modified) (1 diff)
- nbshell/trunk/PlainTextPlugin.py (modified) (8 diffs)
- nbshell/trunk/PythonPlugin.py (modified) (7 diffs)
- nbshell/trunk/Sheet.py (modified) (1 diff)
- nbshell/trunk/ipnDocument.py (modified) (4 diffs)
- nbshell/trunk/ipnPluginTemplate.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
nbshell/trunk/IPythonLog.py
r649 r650 15 15 16 16 from lxml import etree 17 class IPythonLog :17 class IPythonLog(object): 18 18 def __init__(self, doc, notebook, logid, *args, **kwds): 19 19 self.doc = doc … … 121 121 return self.__run(notebook.Cell(self.log[-1])) 122 122 123 cells = [Cell(x) for x in self.log.xpath('\\cell[@number>=%d'%(number,))] 124 cells.sort(key = lambda x:x.number) #That may not be necessary, since the cells are already sorted 125 123 cells = sorted((Cell(x) for x in self.log.xpath('\\cell[@number>=%d'%(number,))), key = lambda x:x.number) 124 126 125 for cell in cells: 127 126 if not self.__run(cell): nbshell/trunk/Main.py
r649 r650 36 36 factory = dict["GetPluginFactory"]() 37 37 #print factory.GetString() #dbg 38 self.plugin_dict[factory. GetString()]=factory38 self.plugin_dict[factory.string]=factory 39 39 40 40 nbshell/trunk/PlainTextPlugin.py
r649 r650 8 8 return PlainTextPluginFactory() 9 9 10 class PlainTextPluginFactory :10 class PlainTextPluginFactory(object): 11 11 """ This class is responsible for creating the document and view parts of 12 12 a plugin. Also it has some functions giving information about the plugin. … … 16 16 returned every time the document class wants to get a new one.""" 17 17 18 def GetString(self): 19 """ Returns the type string of the plugin. This is used when a notebook 20 file is loaded. See notebookformat.txt for more info""" 21 return "plaintext" 22 23 def GetType(self): 24 """ Returns the way data should be passed to the plugin. Currently 25 supported types are "raw" and "encoded". See notebookformat.txt for 26 more info""" 27 return "encoded" #Probably only the python code plugin should be raw 18 string = "plaintext" 19 #def GetString(self): 20 # """ Returns the type string of the plugin. This is used when a notebook 21 # file is loaded. See notebookformat.txt for more info""" 22 # return "plaintext" 23 24 type = "encoded" 25 #def GetType(self): 26 # """ Returns the way data should be passed to the plugin. Currently 27 # supported types are "raw" and "encoded". See notebookformat.txt for 28 # more info""" 29 # return "encoded" #Probably only the python code plugin should be raw 28 30 29 31 def CreateDocumentPlugin(self,document, element): … … 52 54 #end GenericPluginFactory 53 55 54 class PlainTextDocumentPlugin :56 class PlainTextDocumentPlugin(object): 55 57 def __init__(self, document, element): 56 58 """Initialization. If element is <sheet> then the text is … … 77 79 78 80 def SetText(self, text): 81 """Sets the text in the document""" 79 82 if self.start: 80 83 self.element.text = text … … 88 91 if self.view is not None: 89 92 self.view.Update() 90 93 94 text = property(GetText, SetText, Clear, doc = """The text contained in this instance""") 91 95 92 96 def LoadData(self, data=None): … … 136 140 [encodefunc(self.data.GetLine(x)) for x in range(0, linecnt-1)] 137 141 138 def SetView(self, view):139 """Set the view for the plugin"""140 self.view=view141 142 def GetViewPlugin(self, view):143 return self.view142 #def SetView(self, view): 143 # """Set the view for the plugin""" 144 # self.view=view 145 146 #def GetViewPlugin(self, view): 147 # return self.view 144 148 145 149 def GetFactory(self): 146 150 return PlainTextPluginFactory() 147 151 148 class PlainTextNotebookViewPlugin :152 class PlainTextNotebookViewPlugin(object): 149 153 def __init__(self, docplugin, view): 150 154 """Initialization""" 151 155 self.view = view 152 156 self.doc = docplugin 153 self.doc. SetView(self)157 self.doc.view = self 154 158 self.window = None 155 159 self.document = docplugin.document … … 177 181 else: 178 182 prevcell = self.document.GetCell(self.doc.index-1) 179 viewplugin = prevcell. GetViewPlugin(self.view)183 viewplugin = prevcell.view 180 184 #print self.doc.index #dbg 181 185 #print viewplugin #dbg … … 200 204 if self.window is None: #then this is the first time Update is called 201 205 self.createWindow() 202 self.window.SetText(self.doc. GetText())206 self.window.SetText(self.doc.text) 203 207 204 208 def UpdateDoc(self): 205 209 """Update data in the document""" 206 self.doc. SetText(self.window.GetText())210 self.doc.text = self.window.GetText() 207 211 208 212 def Close(self, update = True): nbshell/trunk/PythonPlugin.py
r649 r650 33 33 return PythonPluginFactory() 34 34 35 class PythonPluginFactory :35 class PythonPluginFactory(object): 36 36 """ This class is responsible for creating the document and view parts of 37 37 a plugin. Also it has some functions giving information about the plugin. … … 41 41 returned every time the document class wants to get a new one.""" 42 42 43 def GetString(self): 44 """ Returns the type string of the plugin. This is used when a notebook 45 file is loaded. See notebookformat.txt for more info""" 46 return "python" 43 string = "python" 44 #def GetString(self): 45 # """ Returns the type string of the plugin. This is used when a notebook 46 # file is loaded. See notebookformat.txt for more info""" 47 # return "python" 47 48 48 def GetType(self): 49 """ Returns the way data should be passed to the plugin. Currently 50 supported types are "raw" and "encoded". See notebookformat.txt for 51 more info""" 52 return "raw" #Probably only the python code plugin should be raw 49 type = "raw" 50 #def GetType(self): 51 # """ Returns the way data should be passed to the plugin. Currently 52 # supported types are "raw" and "encoded". See notebookformat.txt for 53 # more info""" 54 # return "raw" #Probably only the python code plugin should be raw 53 55 54 56 def CreateDocumentPlugin(self,document, ipython_block): … … 78 80 79 81 80 class PythonDocumentPlugin :82 class PythonDocumentPlugin(object): 81 83 def __init__(self, document, ipython_block): 82 84 """Initialization. ipython-block is a Elemtent object holding a … … 153 155 #[encodefunc(self.data.GetLine(x)) for x in range(0, linecnt-1)] 154 156 155 def SetView(self, view):156 """Set the view for the plugin"""157 self.view=view157 #def SetView(self, view): 158 #" """Set the view for the plugin""" 159 # self.view=view 158 160 159 def GetViewPlugin(self, view):160 return self.view161 #def GetViewPlugin(self, view): 162 # return self.view 161 163 162 164 def GetFactory(self): … … 169 171 # the code should be easier. Also the methods which should not be used outside the class start 170 172 # with a lowercaps letter. 171 class PythonNotebookViewPlugin :173 class PythonNotebookViewPlugin(object): 172 174 def __init__(self, docplugin, view): 173 175 """Initialization""" 174 176 self.view = view 175 177 self.doc = docplugin 176 self.doc. SetView(self)178 self.doc.view = self 177 179 self.window = None 178 180 self.document = docplugin.document … … 205 207 #print "adding cell" #dbg 206 208 prevcell = self.document.GetCell(self.doc.index-1) 207 viewplugin = prevcell. GetViewPlugin(self.view)209 viewplugin = prevcell.view 208 210 #print self.doc.index #dbg 209 211 #print viewplugin #dbg … … 401 403 self.view.DeleteCell(index, update) 402 404 403 class ShellFacade :405 class ShellFacade(object): 404 406 """Simplified interface to all shell-related functionality. 405 407 nbshell/trunk/Sheet.py
r649 r650 2 2 from lxml import etree 3 3 4 class Sheet :4 class Sheet(object): 5 5 def __init__(self, doc, notebook): 6 6 self.doc = doc nbshell/trunk/ipnDocument.py
r649 r650 24 24 25 25 26 class ipnDocument :26 class ipnDocument(object): 27 27 def __init__(self, app, notebookview): 28 28 … … 80 80 self.fileinfo["init"] = False 81 81 for cell in self.celllist: 82 cell. GetViewPlugin(self.view).Close(update=False)82 cell.view.Close(update=False) 83 83 self.delCell(cell.index) 84 84 … … 120 120 args = line[7:].lstrip().split() 121 121 cell = self.InsertCell(args[0], update=False) 122 t = self.app.plugin_dict[args[0]]. GetType()122 t = self.app.plugin_dict[args[0]].type 123 123 if t == "raw": #pass raw data to the cell 124 124 cnt = cell.LoadRaw(f, args) … … 181 181 for cell in self.celllist: 182 182 factory = cell.GetFactory() 183 celltype = factory. GetType()183 celltype = factory.type 184 184 args = " ".join(cell.GetArgs()) #TODO: check if the argumens don't use bad symbols as EOL for example 185 185 f.write("#@cell "+args + "\n") nbshell/trunk/ipnPluginTemplate.py
r649 r650 9 9 return GenericPluginFactory() 10 10 11 class GenericPluginFactory :11 class GenericPluginFactory(object): 12 12 """ This class is responsible for creating the document and view parts of 13 13 a plugin. Also it has some functions giving information about the plugin. … … 17 17 returned every time the document class wants to get a new one.""" 18 18 19 def GetString(self): 20 """ Returns the type string of the plugin. This is used when a notebook 21 file is loaded. See notebookformat.txt for more info""" 22 return "generic" 19 string = "generic" 20 type = "encoded" 21 #def GetString(self): 22 # """ Returns the type string of the plugin. This is used when a notebook 23 # file is loaded. See notebookformat.txt for more info""" 24 # return "generic" 23 25 24 26 #TODO: remove this … … 55 57 56 58 #TODO: This class makes no sense with the xml file format. Remove it. 57 class GenericDocumentPlugin :59 class GenericDocumentPlugin(object): 58 60 """ objects of this class are responsible for storing data, serializing and 59 61 loding data, and updating the view plugins""" … … 117 119 pass 118 120 119 def SetView(self, view):120 """Set the view for the plugin"""121 self.view=view121 #def SetView(self, view): 122 # """Set the view for the plugin""" 123 # self.view=view 122 124 123 125 def GetFactory(self): … … 125 127 return GenericPluginFactory() 126 128 127 class GenericNotebookViewPlugin :129 class GenericNotebookViewPlugin(object): 128 130 """A generic view plugin. Used for handling data display.""" 129 131 def __init__(self, docplugin, view):
