Exemplo n.º 1
0
 def store(self):
     """Store user's catalogs to the Preferences file."""
     items = self._items()
     cfg = Configuration(True)
     old_versions = cfg.options('Versions') \
         if cfg.has_section('Versions') else []
     new_versions = [i[0] for i in items]
     for label in old_versions:
         if label not in new_versions:
             cfg.remove_option('Versions', label)
             if CFG.has_option('Versions', label):
                 CFG.remove_option('Versions', label)
     for label, path in items:
         if not cfg.has_section('Versions'):
             cfg.add_section('Versions')
         cfg.set('Versions', label, path)
         CFG.set('Versions', label, path)
     with open(cfg.userrc, 'w') as pref:
         cfg.write(pref)
Exemplo n.º 2
0
    def restore(self):
        """Restore user's catalogs to the Preferences file."""
        self._clear()

        cfg = Configuration(True)
        versions = cfg.options('Versions') \
            if cfg.has_section('Versions') else []
        for label in versions:
            path = cfg.get('Versions', label)
            self._addItem(label, path)