@classmethod
    def imageNamed_withCount_(self, name, count):
        
        # some magic values
        NSBoldFontMask = 2
        badgeFontSize = 11
        badgeFontFamilyName = u'Helvetica'
        rrRadius = 7.0
        
        if count == 0:
            # no badge if there are no updates
            return super(MSCBadgedTemplateImage, self).imageNamed_(name)
        # build badge string and get its size
        badgeString = NSString.stringWithString_(unicode(count))
        badgeFont = NSFontManager.sharedFontManager().fontWithFamily_traits_weight_size_(
                        badgeFontFamilyName, NSBoldFontMask, 0, badgeFontSize)
        stringAttributes = { NSFontAttributeName: badgeFont }
        textSize = badgeString.sizeWithAttributes_(stringAttributes)
        
        # use textSize as the basis for the badge outline rect
        badgeOutlineHeight = textSize.height
        badgeOutlineWidth = textSize.width + rrRadius
        if textSize.height > badgeOutlineWidth:
            badgeOutlineWidth = badgeOutlineHeight
        
        # get our base image
        baseImage = super(MSCBadgedTemplateImage, self).imageNamed_(name).copy()
        
        # size our composite image large enough to include the badge
        compositeImageSize = NSMakeSize(baseImage.size().width + badgeOutlineHeight,
                                        baseImage.size().height + badgeOutlineHeight)
        # layout the rect for the text
        badgeStringRect = NSMakeRect(compositeImageSize.width - textSize.width,
                                     compositeImageSize.height - textSize.height,
                                     textSize.width, textSize.height)
        # layout the rect for the badge outline
        badgeOutlineRect = NSMakeRect(compositeImageSize.width - badgeOutlineWidth,
                                      compositeImageSize.height - badgeOutlineHeight,
                                      badgeOutlineWidth, badgeOutlineHeight)
                                      
        # shift the rects around to look better. These are magic numbers.
        badgeStringRect = NSOffsetRect(badgeStringRect, -4.75, -2)
        badgeOutlineRect = NSOffsetRect(badgeOutlineRect, -1, -5)
        
        # our erase rect needs to be a little bigger than the badge itself
        badgeEraseRect = NSInsetRect(badgeOutlineRect, -1.5, -1.5)
        
        # build paths for the badge outline and the badge erase mask
        badgeOutline = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(
                           badgeOutlineRect, rrRadius, rrRadius)
        badgeEraseMask = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(
                             badgeEraseRect, rrRadius, rrRadius)
                             
        # start drawing our composite image
        compositeImage = NSImage.alloc().initWithSize_(compositeImageSize)
        compositeImage.lockFocus()
        
        # draw base image
        baseImageOrigin = NSMakePoint(badgeOutlineHeight/2, badgeOutlineHeight/2)
        baseImage.drawAtPoint_fromRect_operation_fraction_(
            baseImageOrigin, NSZeroRect, NSCompositeCopy, 1.0)
            
        # erase the part that the badge will be drawn over
        NSGraphicsContext.saveGraphicsState()
        NSGraphicsContext.currentContext().setCompositingOperation_(NSCompositeCopy)
        NSColor.blackColor().colorWithAlphaComponent_(0.0).setFill()
        badgeEraseMask.fill()
        NSGraphicsContext.restoreGraphicsState()
        
        # draw badge outline
        badgeOutline.stroke()
        
        # draw count string
        badgeString.drawWithRect_options_attributes_(badgeStringRect, 0, stringAttributes)
        
        # all done drawing!
        compositeImage.unlockFocus()
        compositeImage.setTemplate_(True)
        return compositeImage
Transform a string to upper case.
dataset/ETHPy150Open munki/munki/code/apps/Managed Software Center/Managed Software Center/MSCBadgedTemplateImage.py/MSCBadgedTemplateImage.imageNamed_withCount_--crossover with--dataset/ETHPy150Open alecthomas/voluptuous/voluptuous/util.py/Upper