Skip to content

Commit

Permalink
text_utils.py: remove firstByBarBytes
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Jan 15, 2022
1 parent 496d3e9 commit b755876
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 28 deletions.
13 changes: 0 additions & 13 deletions pyglossary/text_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def fixUtf8(st: "AnyStr") -> str:
pattern_bar_us = re.compile(r"((?<!\\)(?:\\\\)*)\\\|")
pattern_bar_sp = re.compile(r"(?:(?<!\\)(?:\\\\)*)\|")
b_pattern_bar_us = re.compile(r"((?<!\\)(?:\\\\)*)\\\|".encode("ascii"))
b_pattern_bar_first = re.compile(r"(?:(?<!\\)(?:\\\\)*)(\|)".encode("ascii"))


def replaceStringTable(
Expand Down Expand Up @@ -142,18 +141,6 @@ def unescapeBarBytes(st: bytes) -> bytes:
return st


def firstByBarBytes(st: bytes) -> bytes:
"""
splits by "|" (and not "\\|") then unescapes Newline (\\n),
Tab (\\t), Baskslash (\\) and Bar (\\|) in the first part
returns a bytes
"""
m = b_pattern_bar_first.search(st)
if m is None:
return unescapeBarBytes(st)
return unescapeBarBytes(st[:m.start(1)])


# return a message string describing the current exception
def excMessage() -> str:
i = sys.exc_info()
Expand Down
15 changes: 0 additions & 15 deletions tests/text_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,6 @@ def test_unescapeBarBytes(self):
self.assertEqual(b"\\", f(b"\\\\"))
self.assertEqual(b"\\|", f(b"\\\\\\|"))

def test_firstByBarBytes(self):
f = firstByBarBytes
self.assertEqual(f(b""), b"")
self.assertEqual(f(b"|"), b"")
self.assertEqual(f(b"a"), b"a")
self.assertEqual(f(b"a|"), b"a")
self.assertEqual(f(b"|a"), b"")
self.assertEqual(f(b"a|b"), b"a")
self.assertEqual(f(b"a\\|b"), b"a|b")
self.assertEqual(f(b"a\\|b|c"), b"a|b")
self.assertEqual(f(b"a\\\\1|b|c"), b"a\\1")
self.assertEqual(f(b"a\\\\|b|c"), b"a\\")
self.assertEqual(f(b"a\\\\\\|b|c"), b"a\\|b")
self.assertEqual(f(b"a\\\\\\\\|b|c"), b"a\\\\")

def test_formatHMS(self):
f = formatHMS
self.assertEqual(f(0, 0, 0), "00")
Expand Down

0 comments on commit b755876

Please sign in to comment.