Exemplo n.º 1
0
 def save_historylog(self):
     """Save current history log (all text in console)"""
     title = _("Save history log")
     self.emit(SIGNAL('redirect_stdio(bool)'), False)
     filename, _selfilter = getsavefilename(self, title,
                 self.historylog_filename, "%s (*.log)" % _("History logs"))
     self.emit(SIGNAL('redirect_stdio(bool)'), True)
     if filename:
         filename = osp.normpath(filename)
         try:
             encoding.write(unicode(self.get_text_with_eol()), filename)
             self.historylog_filename = filename
             CONF.set('main', 'historylog_filename', filename)
         except EnvironmentError, error:
             QMessageBox.critical(self, title,
                                  _("<b>Unable to save file '%s'</b>"
                                    "<br><br>Error message:<br>%s"
                                    ) % (osp.basename(filename),
                                         unicode(error)))
Exemplo n.º 2
0
 def save_historylog(self):
     """Save current history log (all text in console)"""
     title = _("Save history log")
     self.emit(SIGNAL('redirect_stdio(bool)'), False)
     filename, _selfilter = getsavefilename(
         self, title, self.historylog_filename,
         "%s (*.log)" % _("History logs"))
     self.emit(SIGNAL('redirect_stdio(bool)'), True)
     if filename:
         filename = osp.normpath(filename)
         try:
             encoding.write(unicode(self.get_text_with_eol()), filename)
             self.historylog_filename = filename
             CONF.set('main', 'historylog_filename', filename)
         except EnvironmentError, error:
             QMessageBox.critical(
                 self, title,
                 _("<b>Unable to save file '%s'</b>"
                   "<br><br>Error message:<br>%s") %
                 (osp.basename(filename), unicode(error)))
Exemplo n.º 3
0
 def add_to_history(self, command):
     """Add command to history"""
     command = unicode(command)
     if command in ['', '\n'] or command.startswith('Traceback'):
         return
     if command.endswith('\n'):
         command = command[:-1]
     self.histidx = None
     if len(self.history)>0 and self.history[-1] == command:
         return
     self.history.append(command)
     text = os.linesep + command
     
     # When the first entry will be written in history file,
     # the separator will be append first:
     if self.history_filename not in HISTORY_FILENAMES:
         HISTORY_FILENAMES.append(self.history_filename)
         text = self.SEPARATOR + text
     
     encoding.write(text, self.history_filename, mode='ab')
     self.emit(SIGNAL('append_to_history(QString,QString)'),
               self.history_filename, text)
Exemplo n.º 4
0
def create_script(fname):
    """Create a new Python script"""
    text = os.linesep.join(["# -*- coding: utf-8 -*-", "", ""])
    encoding.write(unicode(text), fname, 'utf-8')
Exemplo n.º 5
0
def create_script(fname):
    """Create a new Python script"""
    text = os.linesep.join(["# -*- coding: utf-8 -*-", "", ""])
    encoding.write(unicode(text), fname, "utf-8")