def makeViewMenu(): """ Submenu consisting of... [X] <Page 1> [ ] <Page 2> [ ] etc... Color (Submenu) """ viewMenu = cli.menu.item.Submenu("View") control = cli.controller.getController() if control.getPageCount() > 0: pageGroup = cli.menu.item.SelectionGroup(control.setPage, control.getPage()) for i in range(control.getPageCount()): pagePanels = control.getDisplayPanels(pageNumber = i, includeSticky = False) label = " / ".join([str_tools.to_camel_case(panel.getName()) for panel in pagePanels]) viewMenu.add(cli.menu.item.SelectionMenuItem(label, pageGroup, i)) if uiTools.isColorSupported(): colorMenu = cli.menu.item.Submenu("Color") colorGroup = cli.menu.item.SelectionGroup(uiTools.setColorOverride, uiTools.getColorOverride()) colorMenu.add(cli.menu.item.SelectionMenuItem("All", colorGroup, None)) for color in uiTools.COLOR_LIST: colorMenu.add(cli.menu.item.SelectionMenuItem(str_tools.to_camel_case(color), colorGroup, color)) viewMenu.add(colorMenu) return viewMenu
def makeGraphMenu(graphPanel): """ Submenu for the graph panel, consisting of... [X] <Stat 1> [ ] <Stat 2> [ ] <Stat 2> Resize... Interval (Submenu) Bounds (Submenu) Arguments: graphPanel - instance of the graph panel """ graphMenu = cli.menu.item.Submenu("Graph") # stats options statGroup = cli.menu.item.SelectionGroup(graphPanel.setStats, graphPanel.getStats()) availableStats = graphPanel.stats.keys() availableStats.sort() for statKey in ["None"] + availableStats: label = str_tools.to_camel_case(statKey, divider=" ") statKey = None if statKey == "None" else statKey graphMenu.add( cli.menu.item.SelectionMenuItem(label, statGroup, statKey)) # resizing option graphMenu.add(cli.menu.item.MenuItem("Resize...", graphPanel.resizeGraph)) # interval submenu intervalMenu = cli.menu.item.Submenu("Interval") intervalGroup = cli.menu.item.SelectionGroup( graphPanel.setUpdateInterval, graphPanel.getUpdateInterval()) for i in range(len(cli.graphing.graphPanel.UPDATE_INTERVALS)): label = cli.graphing.graphPanel.UPDATE_INTERVALS[i][0] label = str_tools.to_camel_case(label, divider=" ") intervalMenu.add( cli.menu.item.SelectionMenuItem(label, intervalGroup, i)) graphMenu.add(intervalMenu) # bounds submenu boundsMenu = cli.menu.item.Submenu("Bounds") boundsGroup = cli.menu.item.SelectionGroup(graphPanel.setBoundsType, graphPanel.getBoundsType()) for boundsType in cli.graphing.graphPanel.Bounds: boundsMenu.add( cli.menu.item.SelectionMenuItem(boundsType, boundsGroup, boundsType)) graphMenu.add(boundsMenu) return graphMenu
def makeGraphMenu(graphPanel): """ Submenu for the graph panel, consisting of... [X] <Stat 1> [ ] <Stat 2> [ ] <Stat 2> Resize... Interval (Submenu) Bounds (Submenu) Arguments: graphPanel - instance of the graph panel """ graphMenu = cli.menu.item.Submenu("Graph") # stats options statGroup = cli.menu.item.SelectionGroup(graphPanel.setStats, graphPanel.getStats()) availableStats = graphPanel.stats.keys() availableStats.sort() for statKey in ["None"] + availableStats: label = str_tools.to_camel_case(statKey, divider = " ") statKey = None if statKey == "None" else statKey graphMenu.add(cli.menu.item.SelectionMenuItem(label, statGroup, statKey)) # resizing option graphMenu.add(cli.menu.item.MenuItem("Resize...", graphPanel.resizeGraph)) # interval submenu intervalMenu = cli.menu.item.Submenu("Interval") intervalGroup = cli.menu.item.SelectionGroup(graphPanel.setUpdateInterval, graphPanel.getUpdateInterval()) for i in range(len(cli.graphing.graphPanel.UPDATE_INTERVALS)): label = cli.graphing.graphPanel.UPDATE_INTERVALS[i][0] label = str_tools.to_camel_case(label, divider = " ") intervalMenu.add(cli.menu.item.SelectionMenuItem(label, intervalGroup, i)) graphMenu.add(intervalMenu) # bounds submenu boundsMenu = cli.menu.item.Submenu("Bounds") boundsGroup = cli.menu.item.SelectionGroup(graphPanel.setBoundsType, graphPanel.getBoundsType()) for boundsType in cli.graphing.graphPanel.Bounds: boundsMenu.add(cli.menu.item.SelectionMenuItem(boundsType, boundsGroup, boundsType)) graphMenu.add(boundsMenu) return graphMenu
def makeViewMenu(): """ Submenu consisting of... [X] <Page 1> [ ] <Page 2> [ ] etc... Color (Submenu) """ viewMenu = cli.menu.item.Submenu("View") control = cli.controller.getController() if control.getPageCount() > 0: pageGroup = cli.menu.item.SelectionGroup(control.setPage, control.getPage()) for i in range(control.getPageCount()): pagePanels = control.getDisplayPanels(pageNumber=i, includeSticky=False) label = " / ".join([ str_tools.to_camel_case(panel.getName()) for panel in pagePanels ]) viewMenu.add(cli.menu.item.SelectionMenuItem(label, pageGroup, i)) if uiTools.isColorSupported(): colorMenu = cli.menu.item.Submenu("Color") colorGroup = cli.menu.item.SelectionGroup(uiTools.setColorOverride, uiTools.getColorOverride()) colorMenu.add(cli.menu.item.SelectionMenuItem("All", colorGroup, None)) for color in uiTools.COLOR_LIST: colorMenu.add( cli.menu.item.SelectionMenuItem(str_tools.to_camel_case(color), colorGroup, color)) viewMenu.add(colorMenu) return viewMenu
def test_to_camel_case(self): """ Checks the to_camel_case() function. """ # test the pydoc example self.assertEquals("I Like Pepperjack!", str_tools.to_camel_case("I_LIKE_PEPPERJACK!")) # check a few edge cases self.assertEquals("", str_tools.to_camel_case("")) self.assertEquals("Hello", str_tools.to_camel_case("hello")) self.assertEquals("Hello", str_tools.to_camel_case("HELLO")) self.assertEquals("Hello World", str_tools.to_camel_case("hello__world")) self.assertEquals("Hello\tworld", str_tools.to_camel_case("hello\tWORLD")) self.assertEquals("Hello\t\tWorld", str_tools.to_camel_case("hello__world", "_", "\t"))