def command_add_to_play_list(screen, filename): paint_screen(gl.BLACK) normal_cursor() gl.SORT_HIT = 1 small_font = pygame.font.Font(gl.FONT_NAME, 10) f = open(gl.IMGV_PLAYLISTS) file_names = f.readlines() if len(file_names) == 0: return (file_names, None, None, None, None) f.close() file_names.sort(lambda x, y: cmp(x.lower(), y.lower())) for count in range(len(file_names)): file_names[count] = file_names[count].replace('\n', '') (list_names, play_list_name, x, my_string) = command_file_master(screen,\ file_names, "LEFT-CLICK list name to add to list", 25, 0, 1, 0) if (list_names == None): return play_list = gl.DATA_DIR + play_list_name f = open(play_list, 'a') if os.path.isdir(filename): filez = dir_nav.get_imgs(os.getcwd(), 0) filez.sort(lambda x, y: cmp(x.lower(), y.lower())) for file in filez: f.write(file + "\n") else: if os.sep not in filename and filename.startswith("http:") != 1: filename = os.getcwd() + os.sep + filename + "\n" f.write(filename + "\n") f.close() normal_cursor()
if not os.path.exists(dir_or_file): # make a full path if user didn't (i.e., they typed "../foo/bar/bla.jpg") dir_or_file = BASE_DIR + os.sep + dir_or_file # set initial directory values CACHE_DIRS = os.listdir(START_DIRECTORY_VAL) CACHE_DIRS = strip_dirs(CACHE_DIRS) CACHE_DIR_OK = 0 if os.path.isdir(dir_or_file) or os.path.isdir(dir_or_file + os.sep): os.chdir(dir_or_file) DRIVE = dir_or_file.split(":")[0] # store only image files in 'files' files = get_imgs(os.getcwd(), 0) elif os.path.isfile(dir_or_file): if dir_or_file[1] == ":" and dir_or_file[2] == os.sep: os.chdir(os.path.dirname(dir_or_file)) files = [dir_or_file] elif dir_or_file[:5] == "http:": REMOTE = 1 files = [dir_or_file] else: errorbox("Invalid File or Directory", os.path.basename(dir_or_file)) MENU_ITEMS_SHORT = [ " Directory Browser ", " Extract from Web ", " Playlists ",