| 41 | | dirlist = os.listdir(self.plugin_dir) |
|---|
| 42 | | regexpr = re.compile('\.py$') #TODO: check if this works for Unicode |
|---|
| 43 | | modlist = filter(lambda x:regexpr.search(x)!=None,dirlist) |
|---|
| 44 | | #print modlist #dbg |
|---|
| 45 | | for module in modlist: |
|---|
| 46 | | try: |
|---|
| 47 | | dict = globals().copy() |
|---|
| 48 | | exec "from nbshell."+module[0:-3] +" import GetPluginFactory" in dict |
|---|
| 49 | | except: |
|---|
| 50 | | if module[0:-3]=="PythonPlugin": |
|---|
| 51 | | raise |
|---|
| 52 | | else: |
|---|
| 53 | | factory = dict["GetPluginFactory"]() |
|---|
| 54 | | #print factory.GetString() #dbg |
|---|
| 55 | | self.plugin_dict[factory.string]=factory |
|---|
| | 41 | #dirlist = os.listdir(self.plugin_dir) |
|---|
| | 42 | #regexpr = re.compile('\.py$') #TODO: check if this works for Unicode |
|---|
| | 43 | #modlist = filter(lambda x:regexpr.search(x)!=None,dirlist) |
|---|
| | 44 | ##print modlist #dbg |
|---|
| | 45 | #for module in modlist: |
|---|
| | 46 | # try: |
|---|
| | 47 | # dict = globals().copy() |
|---|
| | 48 | # exec "from nbshell."+module[0:-3] +" import GetPluginFactory" in dict |
|---|
| | 49 | # except: |
|---|
| | 50 | # if module[0:-3]=="PythonPlugin": |
|---|
| | 51 | # raise |
|---|
| | 52 | # else: |
|---|
| | 53 | # factory = dict["GetPluginFactory"]() |
|---|
| | 54 | # #print factory.GetString() #dbg |
|---|
| | 55 | # self.plugin_dict[factory.string]=factory |
|---|
| | 56 | |
|---|
| | 57 | # Currently there are only two plugins, so we simply add them |
|---|
| | 58 | from nbshell.PythonPlugin import GetPluginFactory |
|---|
| | 59 | factory = GetPluginFactory() |
|---|
| | 60 | self.plugin_dict[factory.string] = factory |
|---|
| | 61 | from nbshell.PlainTextPlugin import GetPluginFactory |
|---|
| | 62 | factory = GetPluginFactory() |
|---|
| | 63 | self.plugin_dict[factory.string] = factory |
|---|
| | 64 | del(GetPluginFactory) |
|---|