Skip to content

Commit b13c842

Browse files
committed
Minor changes
1 parent d9dd4c2 commit b13c842

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

codext/__common__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def list_encodings():
423423
""" Get a list of codext's added encodings from the local registry. """
424424
enc = []
425425
for search_function in __codecs_registry:
426-
enc.append(search_function.__name__)
426+
enc.append(search_function.__name__.replace("_", "-"))
427427
return enc
428428

429429

codext/binary/baudot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def baudot_encode(alphabet=None, spaced=False, tape=False):
190190
ename = "baudot" + ("-spaced" if spaced else "-tape" if tape else "")
191191
alphabet, states, func = _handle_alphabet(alphabet)
192192
def encode(text, errors="strict"):
193-
s, l, state, seen_states = "", len(text), None, []
193+
s, l, state, seen_states = "", len(b(text)), None, []
194194
for i, c in enumerate(text):
195195
# if the state is undefined yet, find the relevant alphabet
196196
if state is None:
@@ -239,7 +239,7 @@ def baudot_decode(alphabet=None, spaced=False, tape=False):
239239
alphabet = {st: {v: k for k, v in alph.items()} for st, alph in alphabet.items()}
240240
states = {v: k for k, v in states.items()}
241241
def decode(text, errors="strict"):
242-
s, l = "", len(text)
242+
s, l = "", len(b(text))
243243
if spaced:
244244
text = text.replace(" ", "")
245245
elif tape:

codext/binary/excess3.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@
2525

2626

2727
def excess3_encode(text, errors="strict"):
28-
r, b = "", ""
28+
r, bits = "", ""
2929
for c in text:
3030
for i in str(ord(c)).zfill(3):
31-
b += CODE[i]
32-
if len(b) == 8:
33-
r += chr(int(b, 2))
34-
b = ""
35-
if len(b) > 0:
36-
r += chr(int(b + "0000", 2))
37-
return r, len(text)
31+
bits += CODE[i]
32+
if len(bits) == 8:
33+
r += chr(int(bits, 2))
34+
bits = ""
35+
if len(bits) > 0:
36+
r += chr(int(bits + "0000", 2))
37+
return r, len(b(text))
3838

3939

4040
def excess3_decode(text, errors="strict"):

0 commit comments

Comments
 (0)