mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-26 21:33:12 +00:00
Reformat everything.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
# This code is part of Ansible, but is an independent component.
|
||||
# This particular file snippet, and this file snippet only, is BSD licensed.
|
||||
# Modules you write using this snippet, which is embedded dynamically by Ansible
|
||||
@@ -50,7 +49,7 @@ def mapping_profile(string):
|
||||
if in_table_c12(c):
|
||||
# map non-ASCII space characters
|
||||
# (that can be mapped) to Unicode space
|
||||
tmp.append(' ')
|
||||
tmp.append(" ")
|
||||
else:
|
||||
tmp.append(c)
|
||||
|
||||
@@ -67,7 +66,7 @@ def is_ral_string(string):
|
||||
# RandALCat character MUST be the last character of the string.
|
||||
if in_table_d1(string[0]):
|
||||
if not in_table_d1(string[-1]):
|
||||
raise ValueError('RFC3454: incorrect bidirectional RandALCat string.')
|
||||
raise ValueError("RFC3454: incorrect bidirectional RandALCat string.")
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -95,41 +94,41 @@ def prohibited_output_profile(string):
|
||||
# If a string contains any RandALCat characters,
|
||||
# The string MUST NOT contain any LCat character:
|
||||
is_prohibited_bidi_ch = in_table_d2
|
||||
bidi_table = 'D.2'
|
||||
bidi_table = "D.2"
|
||||
else:
|
||||
# Forbid RandALCat characters in LCat string:
|
||||
is_prohibited_bidi_ch = in_table_d1
|
||||
bidi_table = 'D.1'
|
||||
bidi_table = "D.1"
|
||||
|
||||
RFC = 'RFC4013'
|
||||
RFC = "RFC4013"
|
||||
for c in string:
|
||||
# RFC4013 2.3. Prohibited Output:
|
||||
if in_table_c12(c):
|
||||
raise ValueError(f'{RFC}: prohibited non-ASCII space characters that cannot be replaced (C.1.2).')
|
||||
raise ValueError(f"{RFC}: prohibited non-ASCII space characters that cannot be replaced (C.1.2).")
|
||||
if in_table_c21_c22(c):
|
||||
raise ValueError(f'{RFC}: prohibited control characters (C.2.1).')
|
||||
raise ValueError(f"{RFC}: prohibited control characters (C.2.1).")
|
||||
if in_table_c3(c):
|
||||
raise ValueError(f'{RFC}: prohibited private Use characters (C.3).')
|
||||
raise ValueError(f"{RFC}: prohibited private Use characters (C.3).")
|
||||
if in_table_c4(c):
|
||||
raise ValueError(f'{RFC}: prohibited non-character code points (C.4).')
|
||||
raise ValueError(f"{RFC}: prohibited non-character code points (C.4).")
|
||||
if in_table_c5(c):
|
||||
raise ValueError(f'{RFC}: prohibited surrogate code points (C.5).')
|
||||
raise ValueError(f"{RFC}: prohibited surrogate code points (C.5).")
|
||||
if in_table_c6(c):
|
||||
raise ValueError(f'{RFC}: prohibited inappropriate for plain text characters (C.6).')
|
||||
raise ValueError(f"{RFC}: prohibited inappropriate for plain text characters (C.6).")
|
||||
if in_table_c7(c):
|
||||
raise ValueError(f'{RFC}: prohibited inappropriate for canonical representation characters (C.7).')
|
||||
raise ValueError(f"{RFC}: prohibited inappropriate for canonical representation characters (C.7).")
|
||||
if in_table_c8(c):
|
||||
raise ValueError(f'{RFC}: prohibited change display properties / deprecated characters (C.8).')
|
||||
raise ValueError(f"{RFC}: prohibited change display properties / deprecated characters (C.8).")
|
||||
if in_table_c9(c):
|
||||
raise ValueError(f'{RFC}: prohibited tagging characters (C.9).')
|
||||
raise ValueError(f"{RFC}: prohibited tagging characters (C.9).")
|
||||
|
||||
# RFC4013, 2.4. Bidirectional Characters:
|
||||
if is_prohibited_bidi_ch(c):
|
||||
raise ValueError(f'{RFC}: prohibited bidi characters ({bidi_table}).')
|
||||
raise ValueError(f"{RFC}: prohibited bidi characters ({bidi_table}).")
|
||||
|
||||
# RFC4013, 2.5. Unassigned Code Points:
|
||||
if in_table_a1(c):
|
||||
raise ValueError(f'{RFC}: prohibited unassigned code points (A.1).')
|
||||
raise ValueError(f"{RFC}: prohibited unassigned code points (A.1).")
|
||||
|
||||
|
||||
def saslprep(string):
|
||||
@@ -151,16 +150,16 @@ def saslprep(string):
|
||||
# comprised of characters from the Unicode [Unicode] character set."
|
||||
# Validate the string is a Unicode string
|
||||
if not is_unicode_str(string):
|
||||
raise TypeError(f'input must be of type str, not {type(string)}')
|
||||
raise TypeError(f"input must be of type str, not {type(string)}")
|
||||
|
||||
# RFC4013: 2.1. Mapping.
|
||||
string = mapping_profile(string)
|
||||
|
||||
# RFC4013: 2.2. Normalization.
|
||||
# "This profile specifies using Unicode normalization form KC."
|
||||
string = normalize('NFKC', string)
|
||||
string = normalize("NFKC", string)
|
||||
if not string:
|
||||
return ''
|
||||
return ""
|
||||
|
||||
# RFC4013: 2.3. Prohibited Output.
|
||||
# RFC4013: 2.4. Bidirectional Characters.
|
||||
|
||||
Reference in New Issue
Block a user