def __init__(self, project=None): " 'project' may be a Project object or a filename. " self.eConfig = config.read_configfile(self, const.CONFIG_FILE) Signals.connect(self, "write-config", (lambda sender: self.write_recentfiles())) self.plugins = dict() self.recent_files = list() self.read_recentfiles() # init() is a good place for initialization of derived class self.init() # Set up the Project... self._project = None if isinstance(project, basestring): try: self.load_project(project) except IOError: logger.error("Failed to load project '%s'\nSetting up an empty project instead." % project) self.set_project(Project()) else: self.set_project(project) self.init_plugins()
def __init__(self, project=None): " 'project' may be a Project object or a filename. " object.__init__(self) # init signals HasSignals.__init__(self) self.sig_register('write-config') self.sig_register('notify::project') self.sig_register('update-recent-files') # init path handler self.path = PathHandler() internal_path = Sloppy.__path__[0] self.path.set('base_dir', internal_path) self.path.set('example_dir', os.path.join(os.path.sep, 'usr', 'share', 'sloppyplot', 'Examples')) self.path.bset('data_dir', 'example_dir', 'Data') self.path.set('logfile', os.path.join(os.path.sep, 'var', 'tmp', 'sloppyplot.log')) self.path.set('current_dir', os.path.curdir) # determine config path if os.environ.has_key('XDG_CONFIG_HOME'): xdg_path = os.path.expandvars('${XDG_CONFIG_HOME}') cfg_path = os.path.join(xdg_path, 'SloppyPlot') else: home_path = os.path.expanduser('~') cfg_path = os.path.join(home_path, '.config', 'SloppyPlot') self.path.set('config_dir', cfg_path) self.path.bset('config', 'config_dir', 'config.xml') print "CONFIG DIR ", self.path.get('config_dir') # init config file self.eConfig = config.read_configfile(self, self.path.get('config')) # set up plugins # initialization is done at then end (TODO: why?) self.plugins = dict() # init recent files self.recent_files = list() self.read_recentfiles() self.sig_connect("write-config", (lambda sender: self.write_recentfiles())) # init() is a good place for initialization of derived class self.init() # Set up the Project... self._project = None if isinstance(project, basestring): try: self.load_project(project) except IOError, msg: logger.error("Failed to load project '%s'\nReason was:\n%s\nSetting up an empty project instead." % (project, msg)) self.set_project(Project())
def __init__(self): SPObject.__init__(self) globals.app = self self._project = None # init signals self.sig_register('write-config') # TODO: self.sig_register('update::project') # TODO: update::recent_files self.sig_register('update-recent-files') # init path handler self.path = PathHandler() # init config file self.eConfig = config.read_configfile(self, self.path.config) # init recent files self.recent_files = [] self.read_recentfiles() self.sig_connect("write-config", self.write_config_recentfiles) # read in existing templates self.read_templates() self.sig_connect("write-config", self.write_config_templates) # init() is a good place for initialization of derived class self.plugins = {} self.load_plugins() self.init() # After everything is initialized, we can set up the project. self.set_project(None) # welcome message self.status_msg("%s %s" % (version.NAME, version.VERSION))