All pastes #127008 Raw Edit

V2 Menu

public python v1 · immutable
·published 2006-08-11 23:22 UTC
rendered paste body
    def getMenu(self, path):        dirs = []   # temp list of subdirs        files = []  # temp list of files        for f in os.listdir(path):            if os.path.isdir(path + "\\" + f):  # found a subdir                dirs.append( (f, path + \\ + f, FOLDER) )   # Add tuple to list            elif f.endswith(".emu"):                title = f   # Make title == filename (for now)                # Extract title from file, place in title variable                files.append( (title, path + \\ + f, EMU) )        dirs.sort(key=lambda obj:obj[0])    # Sort by title        files.sort(key=lambda obj:obj[0])   # Sort by title (not necessarally filename)        return dirs + files # return sorted list, submenus first, then items