Пример #1
0
 def __load_old_defaults(self, old_version):
     """Read old defaults"""
     old_defaults = cp.ConfigParser()
     if check_version(old_version, '3.0.0', '<='):
         path = get_module_source_path('spyderlib')
     else:
         path = osp.dirname(self.filename())
     path = osp.join(path, 'defaults') 
     old_defaults.read(osp.join(path, 'defaults-'+old_version+'.ini'))
     return old_defaults
Пример #2
0
 def __load_old_defaults(self, old_version):
     """Read old defaults"""
     old_defaults = cp.ConfigParser()
     if check_version(old_version, '3.0.0', '<='):
         path = get_module_source_path('spyderlib')
     else:
         path = osp.dirname(self.filename())
     path = osp.join(path, 'defaults') 
     old_defaults.read(osp.join(path, 'defaults-'+old_version+'.ini'))
     return old_defaults
Пример #3
0
 def __load_old_defaults(self, old_version):
     """Read old defaults"""
     old_defaults = cp.ConfigParser()
     if check_version(old_version, "3.0.0", "<="):
         path = get_module_source_path("spyderlib")
     else:
         path = osp.dirname(self.filename())
     path = osp.join(path, "defaults")
     old_defaults.read(osp.join(path, "defaults-" + old_version + ".ini"))
     return old_defaults
Пример #4
0
 def __init__(self,
              name,
              defaults=None,
              load=True,
              version=None,
              subfolder=None,
              backup=False,
              raw_mode=False,
              remove_obsolete=False):
     DefaultsConfig.__init__(self, name, subfolder)
     self.raw = 1 if raw_mode else 0
     if (version is not None) and (re.match('^(\d+).(\d+).(\d+)$', version)
                                   is None):
         raise ValueError(
             "Version number %r is incorrect - must be in X.Y.Z format" %
             version)
     if isinstance(defaults, dict):
         defaults = [(self.DEFAULT_SECTION_NAME, defaults)]
     self.defaults = defaults
     if defaults is not None:
         self.reset_to_defaults(save=False)
     fname = self.filename()
     if backup:
         try:
             shutil.copyfile(fname, "%s.bak" % fname)
         except IOError:
             pass
     if load:
         # If config file already exists, it overrides Default options:
         self.load_from_ini()
         old_ver = self.get_version(version)
         _major = lambda _t: _t[:_t.find('.')]
         _minor = lambda _t: _t[:_t.rfind('.')]
         # Save new defaults
         self.__save_new_defaults(defaults, version, subfolder)
         # Updating defaults only if major/minor version is different
         if _minor(version) != _minor(old_ver):
             if backup:
                 try:
                     shutil.copyfile(fname, "%s-%s.bak" % (fname, old_ver))
                 except IOError:
                     pass
             if check_version(old_ver, '2.4.0', '<'):
                 self.reset_to_defaults(save=False)
             else:
                 self.__update_defaults(defaults, old_ver)
             # Remove deprecated options if major version has changed
             if remove_obsolete or _major(version) != _major(old_ver):
                 self.__remove_deprecated_options(old_ver)
             # Set new version number
             self.set_version(version, save=False)
         if defaults is None:
             # If no defaults are defined, set .ini file settings as default
             self.set_as_defaults()
Пример #5
0
 def __init__(
     self,
     name,
     defaults=None,
     load=True,
     version=None,
     subfolder=None,
     backup=False,
     raw_mode=False,
     remove_obsolete=False,
 ):
     DefaultsConfig.__init__(self, name, subfolder)
     self.raw = 1 if raw_mode else 0
     if (version is not None) and (re.match("^(\d+).(\d+).(\d+)$", version) is None):
         raise ValueError("Version number %r is incorrect - must be in X.Y.Z format" % version)
     if isinstance(defaults, dict):
         defaults = [(self.DEFAULT_SECTION_NAME, defaults)]
     self.defaults = defaults
     if defaults is not None:
         self.reset_to_defaults(save=False)
     fname = self.filename()
     if backup:
         try:
             shutil.copyfile(fname, "%s.bak" % fname)
         except IOError:
             pass
     if load:
         # If config file already exists, it overrides Default options:
         self.load_from_ini()
         old_ver = self.get_version(version)
         _major = lambda _t: _t[: _t.find(".")]
         _minor = lambda _t: _t[: _t.rfind(".")]
         # Save new defaults
         self.__save_new_defaults(defaults, version, subfolder)
         # Updating defaults only if major/minor version is different
         if _minor(version) != _minor(old_ver):
             if backup:
                 try:
                     shutil.copyfile(fname, "%s-%s.bak" % (fname, old_ver))
                 except IOError:
                     pass
             if check_version(old_ver, "2.4.0", "<"):
                 self.reset_to_defaults(save=False)
             else:
                 self.__update_defaults(defaults, old_ver)
             # Remove deprecated options if major version has changed
             if remove_obsolete or _major(version) != _major(old_ver):
                 self.__remove_deprecated_options(old_ver)
             # Set new version number
             self.set_version(version, save=False)
         if defaults is None:
             # If no defaults are defined, set .ini file settings as default
             self.set_as_defaults()
Пример #6
0
    def check_update_available(self, version, releases):
        """Checks if there is an update available.

        It takes as parameters the current version of Spyder and a list of
        valid cleaned releases in chronological order (what github api returns
        by default). Example: ['2.3.4', '2.3.3' ...]
        """
        if is_stable_version(version):
            # Remove non stable versions from the list
            releases = [r for r in releases if is_stable_version(r)]

        latest_release = releases[0]

        if version.endswith('dev'):
            return (False, latest_release)

        return (check_version(version, latest_release, '<'), latest_release)
Пример #7
0
    def check_update_available(self, version, releases):
        """Checks if there is an update available.

        It takes as parameters the current version of Spyder and a list of
        valid cleaned releases in chronological order (what github api returns
        by default). Example: ['2.3.4', '2.3.3' ...]
        """
        if is_stable_version(version):
            # Remove non stable versions from the list
            releases = [r for r in releases if is_stable_version(r)]

        latest_release = releases[0]

        if version.endswith('dev'):
            return (False, latest_release)

        return (check_version(version, latest_release, '<'), latest_release)