def load_ramp(ramp_file): """process a ramp file""" if os.path.isfile(ramp_file): ramp = ColorRamp() try: ramp.deserialize(ramp_file) return ramp except: print "invalid ramp file %s" % ramp_file
def load_ramp_config_file(): """ Reads in ramp files specified in the ramp config file in the ramps directory and creates ramps for them This allows for ordering of the ramps in the config file and for specifying separators """ import os import os.path import string ramps = [] ramp_dir = gview.get_preference('ramp_directory') if ramp_dir is None: ramp_dir = os.path.join(gview.home_dir,'ramps') if os.path.isdir(ramp_dir): config_path = os.path.join(ramp_dir, 'ramps.cfg') if os.path.isfile(config_path): #load config file and parse ramps ... config = open(config_path) lines = config.readlines() for line in lines: ramp_file = string.strip(line) if ramp_file == '<separator>': ramps.append(gtk.GtkHSeparator()) else: ramp_file = os.path.join(ramp_dir, ramp_file) if os.path.isfile(ramp_file): ramp = ColorRamp() try: ramp.deserialize(ramp_file) ramps.append(ramp) ramp.show() except: print 'invalid ramp file %s' % ramp_file else: print 'not a file (%s)' % ramp_file else: print 'no ramps.cfg file, loading ramps directly' return load_ramps() else: print 'no default ramp files in ', ramp_dir return ramps
def load_ramps(): """reads in all the ramp files in the ramps directory and creates ramps for them""" import os import os.path ramps = [] ramp_dir = gview.get_preference('ramp_directory') if ramp_dir is None: ramp_dir = os.path.join(gview.home_dir,'ramps') if os.path.isdir(ramp_dir): files = os.listdir(ramp_dir) for file in files: ramp_file = os.path.join(ramp_dir, file) if os.path.isfile(ramp_file): ramp = ColorRamp() try: ramp.deserialize(ramp_file) ramps.append(ramp) except: print 'invalid ramp file %s' % ramp_file else: print 'no default ramp files in ', ramp_dir return ramps
def load_ramps(): """reads in all the ramp files in the ramps directory and creates ramps for them""" import os import os.path ramps = [] ramp_dir = gview.get_preference('ramp_directory') if ramp_dir is None: ramp_dir = os.path.join(gview.home_dir, 'ramps') if os.path.isdir(ramp_dir): files = os.listdir(ramp_dir) for file in files: ramp_file = os.path.join(ramp_dir, file) if os.path.isfile(ramp_file): ramp = ColorRamp() try: ramp.deserialize(ramp_file) ramps.append(ramp) except: print 'invalid ramp file %s' % ramp_file else: print 'no default ramp files in ', ramp_dir return ramps
def load_ramp_config_file(): """ Reads in ramp files specified in the ramp config file in the ramps directory and creates ramps for them This allows for ordering of the ramps in the config file and for specifying separators """ import os import os.path import string ramps = [] ramp_dir = gview.get_preference('ramp_directory') if ramp_dir is None: ramp_dir = os.path.join(gview.home_dir, 'ramps') if os.path.isdir(ramp_dir): config_path = os.path.join(ramp_dir, 'ramps.cfg') if os.path.isfile(config_path): #load config file and parse ramps ... config = open(config_path) lines = config.readlines() for line in lines: ramp_file = string.strip(line) if ramp_file == '<separator>': ramps.append(gtk.GtkHSeparator()) else: ramp_file = os.path.join(ramp_dir, ramp_file) if os.path.isfile(ramp_file): ramp = ColorRamp() try: ramp.deserialize(ramp_file) ramps.append(ramp) ramp.show() except: print 'invalid ramp file %s' % ramp_file else: print 'not a file (%s)' % ramp_file else: print 'no ramps.cfg file, loading ramps directly' return load_ramps() else: print 'no default ramp files in ', ramp_dir return ramps