Skip to content

Commit

Permalink
Simplify ListName
Browse files Browse the repository at this point in the history
  • Loading branch information
kg583 committed Jun 2, 2024
1 parent c154d1c commit d3ff127
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions tivars/types/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"""


import re

from collections.abc import Iterator, Sequence
from io import BytesIO
from warnings import warn
Expand Down Expand Up @@ -56,18 +54,13 @@ def set(cls, value: _T, **kwargs) -> bytes:
:return: The name encoding of ``value``
"""

varname = value.upper()
varname = re.sub(r"[\u0398\u03F4\u1DBF]", "θ", varname)
varname = re.sub(r"]", "|L", varname)

if not re.fullmatch(r"(L\d)|(\|L|.)?([A-Z]|\u03b8)([0-9A-Z]|\u03b8){,4}|IDList", varname):
warn(f"List has an invalid name: '{varname}'.",
BytesWarning)
# TI-ASCII hack
varname = value.upper().replace("]", "|L")

if "IDList" in varname:
return b'\x5D\x40'

elif re.fullmatch(r"L\d", varname):
elif varname in ("L1", "L2", "L3", "L4", "L5", "L6"):
return super().set(varname[:2])

else:
Expand Down

0 comments on commit d3ff127

Please sign in to comment.