def get_template(template_name, raw=False):
    '''return an html template. If raw is True, just return the string; otherwise
    return a string Template object'''
    customTemplatesPath = os.path.join(msclib.html_dir(), 'custom/templates')
    resourcesPath = NSBundle.mainBundle().resourcePath()
    defaultTemplatesPath = os.path.join(resourcesPath, 'templates')
    for directory in [customTemplatesPath, defaultTemplatesPath]:
        templatePath = os.path.join(directory, template_name)
        if os.path.exists(templatePath):
            try:
                file_ref = open(templatePath)
                template_html = file_ref.read()
                file_ref.close()
                if raw:
                    return template_html.decode('utf-8')
                else:
                    return Template(template_html.decode('utf-8'))
            except (__HOLE__, OSError):
                return None
    return None
dataset/ETHPy150Open munki/munki/code/apps/Managed Software Center/Managed Software Center/mschtml.py/get_template