コード例 #1
0
 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
コード例 #3
0
 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
コード例 #5
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
コード例 #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
コード例 #8
0
 def has_data(self):
     return gimp.parasite_find(self.source_name) is not None
コード例 #9
0
    def clear(self):
        if gimp.parasite_find(self.source_name) is None:
            return

        gimp.parasite_detach(self.source_name)
コード例 #10
0
 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