def filename(self): """ Create a .ini filename located in user home directory """ if TEST is None: folder = get_home_dir() else: import tempfile folder = tempfile.gettempdir() w_dot = osp.join(folder, ".%s.ini" % self.name) if self.subfolder is None: return w_dot else: folder = osp.join(folder, self.subfolder) w_dot = osp.join(folder, ".%s.ini" % self.name) # Save defaults in a "defaults" dir of .spyder2 to not pollute it if "defaults" in self.name: folder = osp.join(folder, "defaults") try: # Copying old config dir for Spyder 3.0. The new config # dir for 3.0+ is going to be simply ~/.spyder{-py3} if __version__.split(".")[0] == "3": if PY2: old_confdir = ".spyder2" else: old_confdir = ".spyder2-py3" old_confdir = osp.join(get_home_dir(), old_confdir) new_confdir = osp.join(get_home_dir(), self.subfolder) if osp.isdir(old_confdir) and not osp.isdir(new_confdir): shutil.copytree(old_confdir, new_confdir) else: os.makedirs(folder) else: os.makedirs(folder) except os.error: # Folder (or one of its parents) already exists pass old, new = w_dot, osp.join(folder, "%s.ini" % self.name) if osp.isfile(old) and DEV is None: try: if osp.isfile(new): os.remove(old) else: os.rename(old, new) except OSError: pass return new
def filename(self): """ Create a .ini filename located in user home directory """ if TEST is None: folder = get_home_dir() else: import tempfile folder = tempfile.gettempdir() w_dot = osp.join(folder, '.%s.ini' % self.name) if self.subfolder is None: return w_dot else: folder = osp.join(folder, self.subfolder) w_dot = osp.join(folder, '.%s.ini' % self.name) # Save defaults in a "defaults" dir of .spyder2 to not pollute it if 'defaults' in self.name: folder = osp.join(folder, 'defaults') try: # Copying old config dir for Spyder 3.0. The new config # dir for 3.0+ is going to be simply ~/.spyder{-py3} if __version__.split('.')[0] == '3': if PY2: old_confdir = '.spyder2' else: old_confdir = '.spyder2-py3' old_confdir = osp.join(get_home_dir(), old_confdir) new_confdir = osp.join(get_home_dir(), self.subfolder) if osp.isdir(old_confdir) and not osp.isdir(new_confdir): shutil.copytree(old_confdir, new_confdir) else: os.makedirs(folder) else: os.makedirs(folder) except os.error: # Folder (or one of its parents) already exists pass old, new = w_dot, osp.join(folder, '%s.ini' % self.name) if osp.isfile(old) and DEV is None: try: if osp.isfile(new): os.remove(old) else: os.rename(old, new) except OSError: pass return new
debug_env = bool(debug_env) return int(debug_env) DEBUG = _get_debug_env() def debug_print(message): """Output debug messages to stdout""" if DEBUG: ss = STDOUT print(message, file=ss) #============================================================================== # Configuration paths #============================================================================== # Spyder settings dir if TEST is None: SUBFOLDER = '.spyder%s' % __version__.split('.')[0] else: SUBFOLDER = 'spyder_test' # We can't have PY2 and PY3 settings in the same dir because: # 1. This leads to ugly crashes and freezes (e.g. by trying to # embed a PY2 interpreter in PY3) # 2. We need to save the list of installed modules (for code # completion) separately for each version if PY3: SUBFOLDER = SUBFOLDER + '-py3' def get_home_dir(): """
# we choose to support only API #2 for 2.4+ import sip try: sip.setapi('QString', 2) sip.setapi('QVariant', 2) sip.setapi('QDate', 2) sip.setapi('QDateTime', 2) sip.setapi('QTextStream', 2) sip.setapi('QTime', 2) sip.setapi('QUrl', 2) except ValueError: import sys if 'spyderlib.spyder' in sys.modules: # Spyder v2 is initializing: it's safe to ignore this exception from spyderlib import __version__ as spyder_ver if int(spyder_ver.split('.')[1]) < 3: print("Warning: deprecated version of Spyder, please upgrade!", file=sys.stderr) else: raise except AttributeError: # PyQt < v4.6. The actual check is done by requirements.check_qt() # call from spyder.py pass try: from PyQt4.QtCore import PYQT_VERSION_STR as __version__ # analysis:ignore except ImportError: # Trying PyQt5 before switching to PySide (at this point, PyQt4 may # not be installed but PyQt5 or Pyside could still be if the QT_API # environment variable hasn't been set-up)
"exclude_regexp": True, "search_text_regexp": True, "search_text": [""], "search_text_samples": [r"# ?TODO|# ?FIXME|# ?XXX"], "in_python_path": False, "more_options": True, }, ), ("pylint", {"enable": True, "max_entries": 50}), ] DEV = not __file__.startswith(sys.prefix) DEV = False from spyderlib import __version__ _subfolder = ".spyder%s" % __version__.split(".")[0] CONF = UserConfig("spyder", defaults=DEFAULTS, load=(not DEV), version="1.0.6", subfolder=_subfolder) # Removing old .spyder.ini location: old_location = osp.join(get_home_dir(), ".spyder.ini") if osp.isfile(old_location): os.remove(old_location) def get_conf_path(filename=None): """Return absolute path for configuration file with specified filename""" conf_dir = osp.join(get_home_dir(), _subfolder) if not osp.isdir(conf_dir): os.mkdir(conf_dir) if filename is None: return conf_dir else: