Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dhondta committed Jul 20, 2020
1 parent d9dd4c2 commit b13c842
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion codext/__common__.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def list_encodings():
""" Get a list of codext's added encodings from the local registry. """
enc = []
for search_function in __codecs_registry:
enc.append(search_function.__name__)
enc.append(search_function.__name__.replace("_", "-"))
return enc


Expand Down
4 changes: 2 additions & 2 deletions codext/binary/baudot.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def baudot_encode(alphabet=None, spaced=False, tape=False):
ename = "baudot" + ("-spaced" if spaced else "-tape" if tape else "")
alphabet, states, func = _handle_alphabet(alphabet)
def encode(text, errors="strict"):
s, l, state, seen_states = "", len(text), None, []
s, l, state, seen_states = "", len(b(text)), None, []
for i, c in enumerate(text):
# if the state is undefined yet, find the relevant alphabet
if state is None:
Expand Down Expand Up @@ -239,7 +239,7 @@ def baudot_decode(alphabet=None, spaced=False, tape=False):
alphabet = {st: {v: k for k, v in alph.items()} for st, alph in alphabet.items()}
states = {v: k for k, v in states.items()}
def decode(text, errors="strict"):
s, l = "", len(text)
s, l = "", len(b(text))
if spaced:
text = text.replace(" ", "")
elif tape:
Expand Down
16 changes: 8 additions & 8 deletions codext/binary/excess3.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@


def excess3_encode(text, errors="strict"):
r, b = "", ""
r, bits = "", ""
for c in text:
for i in str(ord(c)).zfill(3):
b += CODE[i]
if len(b) == 8:
r += chr(int(b, 2))
b = ""
if len(b) > 0:
r += chr(int(b + "0000", 2))
return r, len(text)
bits += CODE[i]
if len(bits) == 8:
r += chr(int(bits, 2))
bits = ""
if len(bits) > 0:
r += chr(int(bits + "0000", 2))
return r, len(b(text))


def excess3_decode(text, errors="strict"):
Expand Down

0 comments on commit b13c842

Please sign in to comment.