def load_and_translate(self, combine, pythonfile, editor, set_current=True):
     """
     Read filename as combine archive, unzip, translate, reconstitute in 
     Python, and create an editor instance and return it
     *Warning* This is loading file, creating editor but not executing
     the source code analysis -- the analysis must be done by the editor
     plugin (in case multiple editorstack instances are handled)
     """
     combine = str(combine)
     self.emit(SIGNAL('starting_long_process(QString)'),
               _("Loading %s...") % combine)
     text, enc = encoding.read(combine)
     text = Translatecombine(combine)
     zipextloctemp, sbmlloclisttemp, sedmlloclisttemp = manifestsearch(combine)
     for i in range(len(text)):
         widgeteditor = editor.editorstacks[0]
         sedmlfname = os.path.basename(sedmlloclisttemp[i])
         finfo = widgeteditor.create_new_editor(os.path.splitext(sedmlfname)[0] + '_phrasedml.py', enc, text[i], set_current, new=True)
         index = widgeteditor.data.index(finfo)
         widgeteditor._refresh_outlineexplorer(index, update=True)
         self.emit(SIGNAL('ending_long_process(QString)'), "")
         if widgeteditor.isVisible() and widgeteditor.checkeolchars_enabled \
          and sourcecode.has_mixed_eol_chars(text[i]):
             name = os.path.basename(pythonfile[:-3] + '_phrasedml.py')
             QMessageBox.warning(self, widgeteditor.title,
                                 _("<b>%s</b> contains mixed end-of-line "
                                   "characters.<br>Spyder will fix this "
                                   "automatically.") % name,
                                 QMessageBox.Ok)
             widgeteditor.set_os_eol_chars(index)
         widgeteditor.is_analysis_done = False
         finfo.editor.set_cursor_position('eof')
         finfo.editor.insert_text(os.linesep)
     return finfo, combine
Example #2
0
 def load_and_translate(self, sbmlfile, pythonfile, editor, set_current=True):
     """
     Read filename as combine archive, unzip, translate, reconstitute in 
     Python, and create an editor instance and return it
     *Warning* This is loading file, creating editor but not executing
     the source code analysis -- the analysis must be done by the editor
     plugin (in case multiple editorstack instances are handled)
     """
     sbmlfile = str(sbmlfile)
     self.emit(SIGNAL('starting_long_process(QString)'),
               _("Loading %s...") % sbmlfile)
     text, enc = encoding.read(sbmlfile)
     sbmlstr = te.readFromFile(sbmlfile)
     text = "import tellurium as te\n\nr = te.loada('''\n" + str(te.sbmlToAntimony(sbmlstr)) + "''')"
     widgeteditor = editor.editorstacks[0]
     finfo = widgeteditor.create_new_editor(pythonfile, enc, text, set_current, new=True)
     index = widgeteditor.data.index(finfo)
     widgeteditor._refresh_outlineexplorer(index, update=True)
     self.emit(SIGNAL('ending_long_process(QString)'), "")
     if widgeteditor.isVisible() and widgeteditor.checkeolchars_enabled \
      and sourcecode.has_mixed_eol_chars(text):
         name = os.path.basename(pythonfile)
         QMessageBox.warning(self, widgeteditor.title,
                             _("<b>%s</b> contains mixed end-of-line "
                               "characters.<br>Spyder will fix this "
                               "automatically.") % name,
                             QMessageBox.Ok)
         widgeteditor.set_os_eol_chars(index)
     widgeteditor.is_analysis_done = False
     finfo.editor.set_cursor_position('eof')
     finfo.editor.insert_text(os.linesep)
     return finfo, sbmlfile
Example #3
0
 def load_and_translate(self, sedmlfile, pythonfile, editor, set_current=True):
     """
     Read filename as SED-ML file, translate it to Python, and
     create an editor instance and return it
     *Warning* This is loading file, creating editor but not executing
     the source code analysis -- the analysis must be done by the editor
     plugin (in case multiple editorstack instances are handled)
     """
     #sedmlfile = to_text_string(sedmlfile)
     sedmlfile = str(sedmlfile)
     self.emit(SIGNAL('starting_long_process(QString)'),
               _("Loading %s...") % sedmlfile)
     text, enc = encoding.read(sedmlfile)
     fname = os.path.basename(sedmlfile)
     temp =  '"End of code generated by Import SED-ML plugin ' + time.strftime("%m/%d/%Y") + '"\n"Extracted from ' + fname + '"\n\n'
     text = te.sedmlToPython(sedmlfile) + temp
     widgeteditor = editor.editorstacks[0]
     finfo = widgeteditor.create_new_editor(pythonfile, enc, text, set_current, new=True)
     index = widgeteditor.data.index(finfo)
     widgeteditor._refresh_outlineexplorer(index, update=True)
     self.emit(SIGNAL('ending_long_process(QString)'), "")
     if widgeteditor.isVisible() and widgeteditor.checkeolchars_enabled \
        and sourcecode.has_mixed_eol_chars(text):
         name = os.path.basename(pythonfile)
         QMessageBox.warning(self, widgeteditor.title,
                             _("<b>%s</b> contains mixed end-of-line "
                               "characters.<br>Spyder will fix this "
                               "automatically.") % name,
                             QMessageBox.Ok)
         widgeteditor.set_os_eol_chars(index)
     widgeteditor.is_analysis_done = False
     finfo.editor.set_cursor_position('eof')
     finfo.editor.insert_text(os.linesep)
     return finfo, sedmlfile
Example #4
0
 def load_and_translate(self, combine, pythonfile, editor, set_current=True):
     """
     Read filename as combine archive, unzip, translate, reconstitute in 
     Python, and create an editor instance and return it
     *Warning* This is loading file, creating editor but not executing
     the source code analysis -- the analysis must be done by the editor
     plugin (in case multiple editorstack instances are handled)
     """
     combine = str(combine)
     self.emit(SIGNAL('starting_long_process(QString)'),
               _("Loading %s...") % combine)
     text, enc = encoding.read(combine)
     text = Translatecombine(combine)
     zipextloctemp, sbmlloclisttemp, sedmlloclisttemp = manifestsearch(combine)
     for i in range(len(text)):
         widgeteditor = editor.editorstacks[0]
         sedmlfname = os.path.basename(sedmlloclisttemp[i])
         finfo = widgeteditor.create_new_editor(os.path.splitext(sedmlfname)[0] + '.py', enc, text[i], set_current, new=True)
         index = widgeteditor.data.index(finfo)
         widgeteditor._refresh_outlineexplorer(index, update=True)
         self.emit(SIGNAL('ending_long_process(QString)'), "")
         if widgeteditor.isVisible() and widgeteditor.checkeolchars_enabled \
          and sourcecode.has_mixed_eol_chars(text[i]):
             name = os.path.basename(os.path.splitext(sedmlfname)[0] + '.py')
             QMessageBox.warning(self, widgeteditor.title,
                                 _("<b>%s</b> contains mixed end-of-line "
                                   "characters.<br>Spyder will fix this "
                                   "automatically.") % name,
                                 QMessageBox.Ok)
             widgeteditor.set_os_eol_chars(index)
         widgeteditor.is_analysis_done = False
         finfo.editor.set_cursor_position('eof')
         finfo.editor.insert_text(os.linesep)
     return finfo, combine
Example #5
0
 def load_and_translate(self,
                        sedmlfile,
                        pythonfile,
                        editor,
                        set_current=True):
     """
     Read filename as SED-ML file, translate it to PhrasedML, and
     create an editor instance and return it
     *Warning* This is loading file, creating editor but not executing
     the source code analysis -- the analysis must be done by the editor
     plugin (in case multiple editorstack instances are handled)
     """
     #sedmlfile = to_text_string(sedmlfile)
     sedmlfile = str(sedmlfile)
     self.emit(SIGNAL('starting_long_process(QString)'),
               _("Loading %s...") % sedmlfile)
     text, enc = encoding.read(sedmlfile)
     fname = os.path.basename(sedmlfile)
     temp = '"End of code generated by Import SED-ML with PhrasedML plugin ' + time.strftime(
         '%m/%d/%Y') + '"\n"Extracted from ' + fname + '"'
     text = "import tellurium as te\n\nphrasedmlStr = '''" + pl.convertFile(
         sedmlfile
     ) + "'''\n\nte.executeSEDML(te.sedml.tephrasedml.phrasedml.convertString(phrasedmlStr))\n\n" + temp
     widgeteditor = editor.editorstacks[0]
     finfo = widgeteditor.create_new_editor(pythonfile,
                                            enc,
                                            text,
                                            set_current,
                                            new=True)
     index = widgeteditor.data.index(finfo)
     widgeteditor._refresh_outlineexplorer(index, update=True)
     self.emit(SIGNAL('ending_long_process(QString)'), "")
     if widgeteditor.isVisible() and widgeteditor.checkeolchars_enabled \
        and sourcecode.has_mixed_eol_chars(text):
         name = os.path.basename(pythonfile)
         QMessageBox.warning(
             self, widgeteditor.title,
             _("<b>%s</b> contains mixed end-of-line "
               "characters.<br>Spyder will fix this "
               "automatically.") % name, QMessageBox.Ok)
         widgeteditor.set_os_eol_chars(index)
     widgeteditor.is_analysis_done = False
     finfo.editor.set_cursor_position('eof')
     finfo.editor.insert_text(os.linesep)
     return finfo, sedmlfile