Skip to content

Commit 5733e54

Browse files
committed
Minor changes
1 parent 1c9334e commit 5733e54

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

codext/__common__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,10 @@ def clear():
405405
def examples(encoding, number=10):
406406
""" Use the search function to get the matching encodings and provide examples of valid encoding names. """
407407
e = []
408-
for n in search(encoding):
408+
for name in search(encoding):
409409
for search_function in __codecs_registry:
410-
if n == search_function.__name__:
410+
n = search_function.__name__
411+
if name in [n, n.replace("_", "-")]:
411412
temp = []
412413
for s in generate_strings_from_regex(search_function.__pattern__, yield_max=16*number):
413414
temp.append(s)
@@ -418,7 +419,7 @@ def examples(encoding, number=10):
418419
e.append(temp[i])
419420
i += 1
420421
for alias, codec in aliases.items():
421-
if n == codec:
422+
if name == codec:
422423
if codec not in e:
423424
e.append(codec)
424425
if not alias.isdigit():
@@ -626,9 +627,10 @@ def search(encoding_regex):
626627
matches = []
627628
for search_function in __codecs_registry:
628629
n = search_function.__name__
629-
if re.search(encoding_regex, n):
630-
matches.append(n)
631-
continue
630+
for name in [n, n.replace("_", "-")]:
631+
if re.search(encoding_regex, name):
632+
matches.append(name)
633+
continue
632634
# in some cases, encoding_regex can match a generated string that uses a particular portion of its generating
633635
# pattern ; e.g. we expect encoding_regex="uu_" to find "uu" and "uu_codec" while it can also find "morse" or
634636
# "atbash" very rarely because of their dynamic patterns and the limited number of randomly generated strings

codext/binary/excess3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
__examples__ = {
1414
'enc(excess3|xs-3|stibitz)': {
15-
'This is a test!': ";t7C\x84H6T8D\x83e<\xa3eD\x944D\x84I6`",
15+
'This is a test!': ";t7C\x84H6T8D\x83e<\xa3eD\x944D\x84I6`",
1616
'This is another test ': ";t7C\x84H6T8D\x83e<\xa4CDDICt4DseD\x944D\x84I6P",
1717
},
1818
'dec(excess-3|xs3)': {

0 commit comments

Comments
 (0)