def testGetWrongPosition(self): self.assertEqual(Sheet.getPosition('fails'), None)
def updateOverview(*args, **kwargs): """ A macro function to update or create a new Overview sheet. Updated sheet will include earlier user data in the old Overview if any. """ try: if not Sheet.checkTemplatesExists(): message_box.showWarningWithOk( 'This file doesn\'t seem to have all necessary templates. Can\'t generate.' ) return # Get name of the Overview which user wants to generate. masterSheet = Master(MASTER_LIST_SHEET_NAME) activeSheetName = kwargs.get('activeSheet', '') if activeSheetName == '': viewName = masterSheet.getOverviewName() overviewSheetName = names.getOverviewName(viewName) else: viewName = names.getViewName(activeSheetName) overviewSheetName = activeSheetName # Some error checking. if not viewName: message_box.showWarningWithOk( 'You can\'t generate an Overview if no View-name is set in cell C1.' ) return if viewName not in masterSheet.getViewNames(): message_box.showWarningWithOk( 'You can\'t generate a View that has no Actions. Make sure at least one ' + 'Action uses the View-name written in cell C1 before continuing.' ) return oldOverview = Overview(viewName) # If document has existing Overview, then that is set as previous instead. if Sheet.hasByName(overviewSheetName): # Check if user wants to update existing Overview. if not message_box.showSheetUpdateWarning(): return oldOverview = Overview.fromSheet(overviewSheetName) newOverview = UpdateOverview.update(oldOverview, viewName) # Place new Overview sheet on the same position as the previous one. If previous one # does not exist, then place right of the Master sheet instead. position = Sheet.getPosition(overviewSheetName) if not position: position = Sheet.getPosition(MASTER_LIST_SHEET_NAME) + 1 # Delete old sheet if exists. Sheet.deleteSheetByName(overviewSheetName) # Generate a new one. formatter = OverviewFormatter(newOverview) unoOverviewSheet = formatter.generate(position) # Make columns width optimal. length = cursor.getWidth(unoOverviewSheet) format.setOptimalWidthToRange(unoOverviewSheet, 0, length) # Fix sheet colors. formatter.setOverviewModifierColors(overviewSheetName) # Set new sheet as currently active sheet. helper.setActiveSheet(unoOverviewSheet) except errors.MovelisterError as e: helper.setActiveSheet(e.activeSheet) message_box.showWarningWithOk(str(e))
def testGetPosition(self): position = Sheet.getPosition(MODIFIER_LIST_SHEET_NAME) self.assertEqual(position, 4)