Esempio n. 1
0
Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved."""

import logging

from M2Crypto import m2, six, util
if util.py27plus:
    from typing import AnyStr, Callable, Iterable, Optional, Union  # noqa

log = logging.getLogger('BIO')


class BIOError(ValueError):
    pass


m2.bio_init(BIOError)


class BIO(object):
    """Abstract object interface to the BIO API."""

    m2_bio_free = m2.bio_free

    def __init__(self, bio=None, _pyfree=0, _close_cb=None):
        # type: (Optional[BIO], int, Optional[Callable]) -> None
        self.bio = bio
        self._pyfree = _pyfree
        self._close_cb = _close_cb
        self.closed = 0
        self.write_closed = 0
Esempio n. 2
0
Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved."""

import io
import logging

from M2Crypto import m2


log = logging.getLogger('BIO')


class BIOError(Exception):
    pass

m2.bio_init(BIOError)


class BIO:

    """Abstract object interface to the BIO API."""

    m2_bio_free = m2.bio_free

    def __init__(self, bio=None, _pyfree=0, _close_cb=None):
        self.bio = bio
        self._pyfree = _pyfree
        self._close_cb = _close_cb
        self.closed = 0
        self.write_closed = 0