def read(self, settings):
   """
   Raises:
   
   * `SettingsNotFoundInSourceError` - see the `SettingSource` class.
   
   * `SettingSourceNotFoundError` - Could not find the specified source.
   
   * `SettingSourceInvalidFormatError` - Specified source has invalid format.
     This could happen if the source was edited manually.
   """
   
   parasite = gimp.parasite_find(self.source_name)
   
   if parasite is None:
     raise SettingSourceNotFoundError(
       _("Could not find setting source \"{0}\".").format(self.source_name)
     )
   
   self._settings_from_parasite = None
   
   try:
     self._settings_from_parasite = pickle.loads(parasite.data)
   except (pickle.UnpicklingError, AttributeError, EOFError):
     raise SettingSourceInvalidFormatError(
       _("Settings for this plug-in stored in the \"{0}\" file are corrupt. "
         "This could happen if the file was edited manually.\n"
         "To fix this, save the settings again or reset them.").format(self._parasite_filename)
     )
   
   self._read(settings)
   
   del self._settings_from_parasite
    def read(self, settings):
        """
    Raises:
    
    * `SettingsNotFoundInSourceError` - see the `SettingSource` class.
    
    * `SettingSourceNotFoundError` - Could not find the specified source.
    
    * `SettingSourceInvalidFormatError` - Specified source has invalid format.
      This could happen if the source was edited manually.
    """

        parasite = gimp.parasite_find(self.source_name)

        if parasite is None:
            raise SettingSourceNotFoundError(
                _("Could not find setting source \"{0}\".").format(
                    self.source_name))

        self._settings_from_parasite = None

        try:
            self._settings_from_parasite = pickle.loads(parasite.data)
        except (pickle.UnpicklingError, AttributeError, EOFError):
            raise SettingSourceInvalidFormatError(
                _("Settings for this plug-in stored in the \"{0}\" file are corrupt. "
                  "This could happen if the file was edited manually.\n"
                  "To fix this, save the settings again or reset them.").
                format(self._parasite_filename))

        self._read(settings)

        del self._settings_from_parasite
 def save_values(self, *values):
     data = []
     for v in values:
         data.append(str(v))
     ndata = "|".join(data)
     if not gimp.parasite_find(PARNAME) == None:
         gimp.parasite_detach(PARNAME)
     gimp.attach_new_parasite(PARNAME, 0, ndata)
예제 #4
0
 def _read_from_parasite(self, parasite_name):
   parasite = gimp.parasite_find(parasite_name)
   if parasite is None:
     return None
   
   try:
     settings_from_parasite = pickle.loads(parasite.data)
   except (pickle.UnpicklingError, AttributeError, EOFError):
     raise pgsettingpersistor.SettingSourceInvalidFormatError(
       _("Settings for this plug-in stored in \"{0}\" may be corrupt. "
         "This could happen if the file was edited manually.\n"
         "To fix this, save the settings again or reset them.").format(self._parasite_file_path))
   
   return settings_from_parasite
    def read_dict(self):
        parasite = gimp.parasite_find(self.source_name)
        if parasite is None:
            return None

        try:
            settings_from_source = pickle.loads(parasite.data)
        except Exception:
            raise SourceInvalidFormatError(
                _('Settings for this plug-in stored in "{}" may be corrupt. '
                  "This could happen if the file was edited manually.\n"
                  "To fix this, save the settings again or reset them.").
                format(self._parasite_filepath))

        return settings_from_source
예제 #6
0
    def _read_from_parasite(self, parasite_name):
        parasite = gimp.parasite_find(parasite_name)
        if parasite is None:
            return None

        try:
            settings_from_parasite = pickle.loads(parasite.data)
        except (pickle.UnpicklingError, AttributeError, EOFError):
            raise pgsettingpersistor.SettingSourceInvalidFormatError(
                _('Settings for this plug-in stored in "{0}" may be corrupt. '
                  "This could happen if the file was edited manually.\n"
                  "To fix this, save the settings again or reset them.").
                format(self._parasite_filepath))

        return settings_from_parasite
예제 #7
0
 def read_dict(self):
   parasite = gimp.parasite_find(self.source_name)
   if parasite is None:
     return None
   
   try:
     settings_from_source = pickle.loads(parasite.data)
   except Exception:
     raise SourceInvalidFormatError(
       _('Settings for this plug-in stored in "{}" may be corrupt. '
         "This could happen if the file was edited manually.\n"
         "To fix this, save the settings again or reset them.").format(
           self._parasite_filepath))
   
   return settings_from_source
 def has_data(self):
     return gimp.parasite_find(self.source_name) is not None
    def clear(self):
        if gimp.parasite_find(self.source_name) is None:
            return

        gimp.parasite_detach(self.source_name)
 def restore_values(self):
     p = gimp.parasite_find(PARNAME)
     if p == None:
         return None
     return p.data.split("|")
예제 #11
0
 def clear(self):
   parasite = gimp.parasite_find(self.source_name)
   if parasite is None:
     return
   
   gimp.parasite_detach(self.source_name)
예제 #12
0
 def has_data(self):
   return gimp.parasite_find(self.source_name) is not None