def load_palettes(self): paldir = self.app.appdata.app_palette_dir loader = get_loader_by_id(uc2const.SKP) for item in config.palette_files.keys(): filepath = os.path.join(paldir, config.palette_files[item]) try: self.palettes[item] = loader(self.app.appdata, filepath, False, False, True) except: if os.path.isfile(filepath): os.remove(filepath) del config.palette_files[item]
def on_click(self, *args): OUT_PATH = '/home/igor/PALETTES/COLLECTION/' IN_PATH = '/home/igor/PALETTES/SORTED/' files = [] for r, d, f in os.walk(IN_PATH): files += f files.sort() pid = 1 loader = get_loader_by_id(SKP) for item in files: print item, pal_id = '0' * (4 - len(str(pid))) + str(pid) dir_path = os.path.join(OUT_PATH, 'id' + pal_id) palfile = os.path.join(IN_PATH, item) if not os.path.exists(dir_path): os.makedirs(dir_path) try: palette = loader(self.app.appdata, palfile, None, False, False) self.process_palette(dir_path, palette, pal_id) print ' => OK' pid += 1 except: print ' => False'