def GenerateGroupPolicyTemplateAdmx(apps):
    'Generates a Group Policy template (ADMX format)for the specified apps.\n\n  Replaces LF in strings above with CRLF as required by gpedit.msc.\n  When writing the resulting contents to a file, use binary mode to ensure the\n  CRLFs are preserved.\n\n  Args:\n    apps: A list of tuples containing information about each app.\n        Each element of the list is a tuple of:\n          * app name\n          * app ID\n          * optional string to append to the auto-update explanation\n            - Should start with a space or double new line.\n\n  Returns:\n    String containing the contents of the .ADMX file.\n  '

    def _GenerateCategories(apps):
        'Generates category string for each of the specified apps.\n\n    Args:\n      apps: list of tuples containing information about the apps.\n\n    Returns:\n      String containing concatenated copies of the category string for each app\n      in apps, each populated with the appropriate app-specific strings.\n    '
        admx_app_category_template = '    <category name="Cat_%(AppLegalId)s"\n        displayName="$(string.Cat_%(AppLegalId)s)">\n      <parentCategory ref="Cat_Applications" />\n    </category>'
        app_category_list = []
        for app in apps:
            app_name = app[0]
            app_category_list.append((admx_app_category_template % {'AppLegalId': _CreateLegalIdentifier(app_name)}))
        return (ADMX_CATEGORIES % {'AppCategorList': '\n'.join(app_category_list)})

    def _GeneratePolicies(apps):
        'Generates policy string for each of the specified apps.\n\n    Args:\n      apps: list of tuples containing information about the apps.\n\n    Returns:\n      String containing concatenated copies of the policy template for each app\n      in apps, each populated with the appropriate app-specific strings.\n    '
        app_policy_list = []
        for app in apps:
            (app_name, app_guid, _, _) = app
            app_policy_list.append((ADMX_APP_POLICY_TEMPLATE % {'AppLegalId': _CreateLegalIdentifier(app_name), 'AppGuid': app_guid, 'RootPolicyKey': MAIN_POLICY_KEY}))
        return (ADMX_POLICIES % {'AppPolicyList': '\n'.join(app_policy_list), 'RootPolicyKey': MAIN_POLICY_KEY})
    target_contents = [ADMX_HEADER, ADMX_ENVIRONMENT, _GenerateCategories(apps), _GeneratePolicies(apps), ADMX_FOOTER]
    return ''.join(target_contents)
Generates a Group Policy template (ADMX format)for the specified apps.

Replaces LF in strings above with CRLF as required by gpedit.msc.
When writing the resulting contents to a file, use binary mode to ensure the
CRLFs are preserved.

Args:
  apps: A list of tuples containing information about each app.
      Each element of the list is a tuple of:
        * app name
        * app ID
        * optional string to append to the auto-update explanation
          - Should start with a space or double new line.

Returns:
  String containing the contents of the .ADMX file.
def GenerateGroupPolicyTemplateAdmx(apps):
    'Generates a Group Policy template (ADMX format)for the specified apps.\n\n  Replaces LF in strings above with CRLF as required by gpedit.msc.\n  When writing the resulting contents to a file, use binary mode to ensure the\n  CRLFs are preserved.\n\n  Args:\n    apps: A list of tuples containing information about each app.\n        Each element of the list is a tuple of:\n          * app name\n          * app ID\n          * optional string to append to the auto-update explanation\n            - Should start with a space or double new line.\n\n  Returns:\n    String containing the contents of the .ADMX file.\n  '

    def _GenerateCategories(apps):
        'Generates category string for each of the specified apps.\n\n    Args:\n      apps: list of tuples containing information about the apps.\n\n    Returns:\n      String containing concatenated copies of the category string for each app\n      in apps, each populated with the appropriate app-specific strings.\n    '
        admx_app_category_template = '    <category name="Cat_%(AppLegalId)s"\n        displayName="$(string.Cat_%(AppLegalId)s)">\n      <parentCategory ref="Cat_Applications" />\n    </category>'
        app_category_list = []
        for app in apps:
            app_name = app[0]
            app_category_list.append((admx_app_category_template % {'AppLegalId': _CreateLegalIdentifier(app_name)}))
        return (ADMX_CATEGORIES % {'AppCategorList': '\n'.join(app_category_list)})

    def _GeneratePolicies(apps):
        'Generates policy string for each of the specified apps.\n\n    Args:\n      apps: list of tuples containing information about the apps.\n\n    Returns:\n      String containing concatenated copies of the policy template for each app\n      in apps, each populated with the appropriate app-specific strings.\n    '
        app_policy_list = []
        for app in apps:
            (app_name, app_guid, _, _) = app
            app_policy_list.append((ADMX_APP_POLICY_TEMPLATE % {'AppLegalId': _CreateLegalIdentifier(app_name), 'AppGuid': app_guid, 'RootPolicyKey': MAIN_POLICY_KEY}))
        return (ADMX_POLICIES % {'AppPolicyList': '\n'.join(app_policy_list), 'RootPolicyKey': MAIN_POLICY_KEY})
    target_contents = [ADMX_HEADER, ADMX_ENVIRONMENT, _GenerateCategories(apps), _GeneratePolicies(apps), ADMX_FOOTER]
    return .join(target_contents)