From 09cff35687e53aa4922a19e9d4c09594997fbee8 Mon Sep 17 00:00:00 2001 From: Tom Gillespie Date: Mon, 10 Feb 2020 16:46:12 -0800 Subject: [PATCH] iterio add missing functions --- pyontutils/iterio.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pyontutils/iterio.py b/pyontutils/iterio.py index e1f974fb..c6277577 100644 --- a/pyontutils/iterio.py +++ b/pyontutils/iterio.py @@ -10,6 +10,21 @@ greenlet = None +def _mixed_join(iterable, sentinel): + """concatenate any string type in an intelligent way.""" + iterator = iter(iterable) + first_item = next(iterator, sentinel) + if isinstance(first_item, bytes): + return first_item + b"".join(iterator) + return first_item + u"".join(iterator) + + +def _newline(reference_string): + if isinstance(reference_string, bytes): + return b"\n" + return u"\n" + + class IterIO(object): """Instances of this object implement an interface compatible with the standard Python :class:`file` object. Streams are either read-only or