Ignore:
Timestamp:
07/02/13 17:42:11 (10 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Changed the default settings filename.

Now using fully qualified import name as the base instead of the
widget caption.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeWidgets/OWBaseWidget.py

    r11592 r11617  
    55# 
    66import warnings 
     7import shutil 
    78 
    89from Orange.utils import environ 
     
    452453 
    453454    def getDefaultSettingsFilename(self): 
     455        """ 
     456        Return a default widget settings filename. 
     457        """ 
     458        settings_dir = self.widgetSettingsDir 
     459        class_ = type(self) 
     460        basename = "%s.%s.pck" % (class_.__module__, class_.__name__) 
     461        filename = os.path.join(settings_dir, basename) 
     462 
     463        if os.path.exists(filename): 
     464            return filename 
     465 
     466        # Try to find the old filename format ({caption}.ini) and 
     467        # copy it to the new place 
    454468        fs_encoding = sys.getfilesystemencoding() 
    455469        basename = self.captionTitle + ".ini" 
    456         filename = os.path.join( 
    457             self.widgetSettingsDir,  # is assumed to be a str in FS encoding 
     470        legacy_filename = os.path.join( 
     471            settings_dir,  # is assumed to be a str in FS encoding 
    458472            basename.encode(fs_encoding)) 
     473 
     474        if os.path.isfile(legacy_filename): 
     475            # Copy the old settings file to the new place. 
     476            shutil.copy(legacy_filename, filename) 
     477 
    459478        return filename 
    460479 
Note: See TracChangeset for help on using the changeset viewer.