Skip to content

Commit

Permalink
iterio add missing functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tgbugs committed Feb 11, 2020
1 parent bfb0d59 commit 09cff35
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pyontutils/iterio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 09cff35

Please sign in to comment.