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
def load_wdhistory(self, workdir=None): """Load history from a text file in user home directory""" if osp.isfile(self.LOG_PATH): wdhistory, _ = encoding.readlines(self.LOG_PATH) wdhistory = [name for name in wdhistory if os.path.isdir(name)] else: if workdir is None: workdir = get_home_dir() wdhistory = [ workdir ] return wdhistory
def load_wdhistory(self, workdir=None): """Load history from a text file in user home directory""" if osp.isfile(self.LOG_PATH): wdhistory, _ = encoding.readlines(self.LOG_PATH) wdhistory = [name for name in wdhistory if os.path.isdir(name)] else: if workdir is None: workdir = get_home_dir() wdhistory = [workdir] return wdhistory
'zenburn/builtin': ('#efef8f', False, False), 'zenburn/definition': ('#efef8f', False, False), 'zenburn/comment': ('#7f9f7f', False, True), 'zenburn/string': ('#cc9393', False, False), 'zenburn/number': ('#8cd0d3', False, False), 'zenburn/instance': ('#dcdccc', False, True) }) ] #============================================================================== # Config instance #============================================================================== # IMPORTANT NOTES: # 1. If you want to *change* the default value of a current option, you need to # do a MINOR update in config version, e.g. from 3.0.0 to 3.1.0 # 2. If you want to *remove* options that are no longer needed in our codebase, # you need to do a MAJOR update in version, e.g. from 3.0.0 to 4.0.0 # 3. You don't need to touch this value if you're just adding a new option CONF_VERSION = '21.1.0' # XXX: Previously we had load=(not DEV) here but DEV was set to *False*. # Check if it *really* needs to be updated or not CONF = UserConfig('spyder', defaults=DEFAULTS, load=True, version=CONF_VERSION, subfolder=SUBFOLDER, backup=True, raw_mode=True) # Removing old .spyder.ini location: old_location = osp.join(get_home_dir(), '.spyder.ini') if osp.isfile(old_location): os.remove(old_location)
'zenburn/number': ('#8cd0d3', False, False), 'zenburn/instance': ('#dcdccc', False, True) }) ] #============================================================================== # Config instance #============================================================================== # IMPORTANT NOTES: # 1. If you want to *change* the default value of a current option, you need to # do a MINOR update in config version, e.g. from 3.0.0 to 3.1.0 # 2. If you want to *remove* options that are no longer needed in our codebase, # you need to do a MAJOR update in version, e.g. from 3.0.0 to 4.0.0 # 3. You don't need to touch this value if you're just adding a new option CONF_VERSION = '21.0.0' # XXX: Previously we had load=(not DEV) here but DEV was set to *False*. # Check if it *really* needs to be updated or not CONF = UserConfig('spyder', defaults=DEFAULTS, load=True, version=CONF_VERSION, subfolder=SUBFOLDER, backup=True, raw_mode=True) # Removing old .spyder.ini location: old_location = osp.join(get_home_dir(), '.spyder.ini') if osp.isfile(old_location): os.remove(old_location)