예제 #1
0
 def synchronize(self):
     """
     Synchronize Spyder's path list with PYTHONPATH environment variable
     Only apply to: current user, on Windows platforms
     """
     answer = QMessageBox.question(self, _("Synchronize"),
         _("This will synchronize Spyder's path list with "
                 "<b>PYTHONPATH</b> environment variable for current user, "
                 "allowing you to run your Python modules outside Spyder "
                 "without having to configure sys.path. "
                 "<br>Do you want to clear contents of PYTHONPATH before "
                 "adding Spyder's path list?"),
         QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
     if answer == QMessageBox.Cancel:
         return
     elif answer == QMessageBox.Yes:
         remove = True
     else:
         remove = False
     from spyderlib.utils.environ import (get_user_env, set_user_env,
                                          listdict2envdict)
     env = get_user_env()
     if remove:
         ppath = self.pathlist+self.ro_pathlist
     else:
         ppath = env.get('PYTHONPATH', [])
         if not isinstance(ppath, list):
             ppath = [ppath]
         ppath = [path for path in ppath
                  if path not in (self.pathlist+self.ro_pathlist)]
         ppath.extend(self.pathlist+self.ro_pathlist)
     env['PYTHONPATH'] = ppath
     set_user_env( listdict2envdict(env), parent=self )
예제 #2
0
 def synchronize(self):
     """
     Synchronize Spyder's path list with PYTHONPATH environment variable
     Only apply to: current user, on Windows platforms
     """
     answer = QMessageBox.question(self, _("Synchronize"),
         _("This will synchronize Spyder's path list with "
                 "<b>PYTHONPATH</b> environment variable for current user, "
                 "allowing you to run your Python modules outside Spyder "
                 "without having to configure sys.path. "
                 "<br>Do you want to clear contents of PYTHONPATH before "
                 "adding Spyder's path list?"),
         QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
     if answer == QMessageBox.Cancel:
         return
     elif answer == QMessageBox.Yes:
         remove = True
     else:
         remove = False
     from spyderlib.utils.environ import (get_user_env, set_user_env,
                                          listdict2envdict)
     env = get_user_env()
     if remove:
         ppath = self.pathlist+self.ro_pathlist
     else:
         ppath = env.get('PYTHONPATH', [])
         if not isinstance(ppath, list):
             ppath = [ppath]
         ppath = [path for path in ppath
                  if path not in (self.pathlist+self.ro_pathlist)]
         ppath.extend(self.pathlist+self.ro_pathlist)
     env['PYTHONPATH'] = ppath
     set_user_env( listdict2envdict(env), parent=self )