コード例 #1
0
ファイル: styles.py プロジェクト: zaheerm/twisted
def unpickleStringO(val, sek):
    """
    Convert the output of L{pickleStringO} into an appropriate type for the
    current python version.  This may be called on Python 3 and will convert a
    cStringIO into an L{io.StringIO}.

    @param val: The content of the file.
    @type val: L{bytes}

    @param sek: The seek position of the file.
    @type sek: L{int}

    @return: a file-like object which you can write bytes to.
    @rtype: L{cStringIO.OutputType} on Python 2, L{io.StringIO} on Python 3.
    """
    x = _cStringIO()
    x.write(val)
    x.seek(sek)
    return x
コード例 #2
0
def unpickleStringO(val, sek):
    """
    Convert the output of L{pickleStringO} into an appropriate type for the
    current python version.  This may be called on Python 3 and will convert a
    cStringIO into an L{io.StringIO}.

    @param val: The content of the file.
    @type val: L{bytes}

    @param sek: The seek position of the file.
    @type sek: L{int}

    @return: a file-like object which you can write bytes to.
    @rtype: L{cStringIO.OutputType} on Python 2, L{io.StringIO} on Python 3.
    """
    x = _cStringIO()
    x.write(val)
    x.seek(sek)
    return x
コード例 #3
0
 def StringIO(*args):
     if args and isinstance(args[0], str):
         return _cStringIO(*args)
     return _PureStringIO(*args)
コード例 #4
0
ファイル: _compat.py プロジェクト: KGerring/concepts
 def StringIO(*args):
     if args and isinstance(args[0], str):
         return _cStringIO(*args)
     return _PureStringIO(*args)