-def chomp(pp):
- """Return the string PP, without its trailing newline if it has one."""
- if len(pp) > 0 and pp[-1] == '\n':
- pp = pp[:-1]
- return pp
-
-def asciip(s):
- """Answer whether all of the characters of S are plain ASCII."""
- for ch in s:
- if ch < ' ' or ch > '~': return False
- return True
-
-def present(s):
- """
- Return a presentation form of the string S.
-
- If S is plain ASCII, then return S unchanged; otherwise return it as one of
- Catacomb's ByteString objects.
- """
- if asciip(s): return s
- return C.ByteString(s)
-