components/policy/tools/template_writers/writers/admx_writer.py
def GetType(policy, allow_multi_strings=False):
    '''Returns the ADMX element type that should be used for the given policy.
    This logic is shared between the ADMX writer and the ADML writer, to ensure
    that the ADMX and ADML generated from policy_tempates.json are compatible.

    Args:
      policy: A dict describing the policy, as found in policy_templates.json.
      allow_multi_strings: If true, the use of multi-line textbox elements is
          allowed, so this function will sometimes return MULTI_STRING. If false
          it falls back to single-line textboxes instead by returning STRING.

    Returns:
      One of the enum values of AdmxElementType.

    Raises:
      Exception: If policy['type'] is not recognized.
    '''
    policy_type = policy['type']
    policy_example = policy.get('example_value')

    # TODO(olsen): Some policies are defined in policy_templates.json as type
    # string, but the string is actually a JSON object. We should change the
    # schema so they are 'dict' or similar, but until then, we use this
    # heuristic to decide whether they are actually JSON and so could benefit
    # from being displayed to the user as a multi-line string:
    if (policy_type == 'string' and allow_multi_strings and
        policy_example is not None and policy_example.strip().startswith('{')):
      return AdmxElementType.MULTI_STRING

    admx_element_type = AdmxElementType._POLICY_TYPE_MAP.get(policy_type)
    if admx_element_type is None:
      raise Exception('Unknown policy type %s.' % policy_type)

    if (admx_element_type == AdmxElementType.MULTI_STRING and
        not allow_multi_strings):
      return AdmxElementType.STRING

    return admx_element_type
Returns the ADMX element type that should be used for the given policy.
    This logic is shared between the ADMX writer and the ADML writer, to ensure
    that the ADMX and ADML generated from policy_tempates.json are compatible.

    Args:
      policy: A dict describing the policy, as found in policy_templates.json.
      allow_multi_strings: If true, the use of multi-line textbox elements is
          allowed, so this function will sometimes return MULTI_STRING. If false
          it falls back to single-line textboxes instead by returning STRING.

    Returns:
      One of the enum values of AdmxElementType.

    Raises:
      Exception: If policy['type'] is not recognized.
    
Returns the ADMX element type that should be used for the given policy.
This logic is shared between the ADMX writer and the ADML writer, to ensure
that the ADMX and ADML generated from policy_tempates.json are compatible.
Returns the ADMX element type that should be used for the given policy . This logic is shared between the ADMX writer and the ADML writer to ensure that the ADMX and ADML generated from policy_tempates . json are compatible .
def GetType(policy, allow_multi_strings=False):
    policy_type = policy['type']
    policy_example = policy.get('example_value')
    if (policy_type == 'string' and allow_multi_strings and
        policy_example is not None and policy_example.strip().startswith('{')):
      return AdmxElementType.MULTI_STRING
    admx_element_type = AdmxElementType._POLICY_TYPE_MAP.get(policy_type)
    if admx_element_type is None:
      raise Exception('Unknown policy type %s.' % policy_type)
    if (admx_element_type == AdmxElementType.MULTI_STRING and
        not allow_multi_strings):
      return AdmxElementType.STRING
    return admx_element_type
def GetType ( policy , allow_multi_strings = False ) : policy_type = policy [ 'type' ] policy_example = policy . get ( 'example_value' ) if ( policy_type == 'string' and allow_multi_strings and policy_example is not None and policy_example . strip ( ) . startswith ( '{' ) ) : return AdmxElementType . MULTI_STRING admx_element_type = AdmxElementType . _POLICY_TYPE_MAP . get ( policy_type ) if admx_element_type is None : raise Exception ( 'Unknown policy type %s.' % policy_type ) if ( admx_element_type == AdmxElementType . MULTI_STRING and not allow_multi_strings ) : return AdmxElementType . STRING return admx_element_type
Returns the ADMX element type that should be used for the given policy.
Returns the ADMX element type that should be used for the given policy .
'''Returns the ADMX element type that should be used for the given policy.
    This logic is shared between the ADMX writer and the ADML writer, to ensure
    that the ADMX and ADML generated from policy_tempates.json are compatible.

    Args:
      policy: A dict describing the policy, as found in policy_templates.json.
      allow_multi_strings: If true, the use of multi-line textbox elements is
          allowed, so this function will sometimes return MULTI_STRING. If false
          it falls back to single-line textboxes instead by returning STRING.

    Returns:
      One of the enum values of AdmxElementType.

    Raises:
      Exception: If policy['type'] is not recognized.
    ''' # TODO(olsen): Some policies are defined in policy_templates.json as type # string, but the string is actually a JSON object. We should change the # schema so they are 'dict' or similar, but until then, we use this # heuristic to decide whether they are actually JSON and so could benefit # from being displayed to the user as a multi-line string:
One of the enum values of AdmxElementType.
One of the enum values of AdmxElementType .
If policy['type'] is not recognized.
If policy [ ' type ' ] is not recognized .
Exception
policy
A dict describing the policy, as found in policy_templates.json.
A dict describing the policy as found in policy_templates . json .
allow_multi_strings
If true, the use of multi-line textbox elements is
allowed, so this function will sometimes return MULTI_STRING. If false
it falls back to single-line textboxes instead by returning STRING.
If true the use of multi - line textbox elements is allowed so this function will sometimes return MULTI_STRING . If false it falls back to single - line textboxes instead by returning STRING .