New filter plugin - unicode_normalization (#3359)

* Initial commit

* Adding maintainer in BOTMETA

* Adding changelog fragment

* Updating filter_guide

* Applying initial review suggestions
This commit is contained in:
Ajpantuso 2021-09-12 07:46:53 -04:00 committed by GitHub
commit 29e4066944
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 122 additions and 0 deletions

View file

@ -0,0 +1,2 @@
shippable/posix/group2
skip/python2.6 # filters are controller only, and we no longer support Python 2.6 on the controller

View file

@ -0,0 +1,39 @@
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- name: Test 'NFC' normalization
assert:
that:
- u_umlaut != u_umlaut_combining
- u_umlaut_combining != (u_umlaut_combining | community.general.unicode_normalize)
- u_umlaut == (u_umlaut_combining | community.general.unicode_normalize)
- name: Test 'NFKC' normalization
assert:
that:
- latin_capital_i != roman_numeral_one
- latin_capital_i == (roman_numeral_one | community.general.unicode_normalize(form='NFKC'))
- name: Register invalid input type
debug:
msg: "{{ 1 | community.general.unicode_normalize }}"
ignore_errors: true
register: invalid_input_type
- name: Assert an invalid input type causes failure
assert:
that:
- invalid_input_type is failed
- name: Register invalid form selection
debug:
msg: "{{ 'arbitrary text' | community.general.unicode_normalize(form='invalid') }}"
ignore_errors: true
register: invalid_form_selection
- name: Assert invalid form selection causes failure
assert:
that:
- invalid_form_selection is failed

View file

@ -0,0 +1,4 @@
u_umlaut: "{{ '\u00fc' }}"
u_umlaut_combining: "{{ 'u' + '\u0308' }}"
roman_numeral_one: "{{ '\u2160' }}"
latin_capital_i: "{{ '\u0049' }}"