- PolicerRoundType, 'ROUND_TO_{rt}'.format(
- rt=round_type.upper())).value,
- type=getattr(PolicerType, 'TYPE_{pt}'.format(
- pt=policer_type.upper())).value,
- conform_action_type=getattr(
- PolicerAction, conform_action_type.upper()).value,
- conform_dscp=getattr(DSCP, 'D_{dscp}'.format(
- dscp=conform_dscp.upper())).value
- if
- conform_action_type.upper() == PolicerAction.MARK_AND_TRANSMIT.name
- else 0,
- exceed_action_type=getattr(
- PolicerAction, exceed_action_type.upper()).value,
- exceed_dscp=getattr(DSCP, 'D_{dscp}'.format(
- dscp=exceed_dscp.upper())).value
- if
- exceed_action_type.upper() == PolicerAction.MARK_AND_TRANSMIT.name
- else 0,
- violate_action_type=getattr(
- PolicerAction, violate_action_type.upper()).value,
- violate_dscp=getattr(DSCP, 'D_{dscp}'.format(
- dscp=violate_dscp.upper())).value
- if
- violate_action_type.upper() == PolicerAction.MARK_AND_TRANSMIT.name
- else 0,
- color_aware=1 if color_aware == "'ca'" else 0
+ PolicerRoundType, f"ROUND_TO_{round_type.upper()}"
+ ).value,
+ type=getattr(PolicerType, f"TYPE_{policer_type.upper()}").value,
+ conform_action=conform_action,
+ exceed_action=exceed_action,
+ violate_action=violate_action,
+ color_aware=bool(color_aware == u"'ca'")