<commit_before>from abc import ABCMeta, abstractmethod
import logging


logger = logging.getLogger("remote.crypt")


class Cryptor(object):
    """Abstract base class for cryptographic objects capable
    of performing encryption and decryption of strings.

    """
    __metaclass__ = ABCMeta

    @abstractmethod
    def encrypt(self, plaintext):
        """Encrypts string plaintext, returning a ciphertext.

        """
        pass

    @abstractmethod
    def decrypt(self, ciphertext):
        """Decrypts string ciphertext, returning a plaintext.

        """
        pass<commit_msg>Turned Cryptor into a stream class.<commit_after>from abc import ABCMeta, abstractmethod
from stream import Stream
import logging


logger = logging.getLogger("remote.crypt")


class Cryptor(Stream):
    """Abstract base class for cryptographic objects capable
    of performing encryption and decryption of strings.

    """
    __metaclass__ = ABCMeta

    @abstractmethod
    def encrypt(self, plaintext):
        """Encrypts string plaintext, returning a ciphertext.

        """
        pass

    @abstractmethod
    def decrypt(self, ciphertext):
        """Decrypts string ciphertext, returning a plaintext.

        """
        pass

    def read(self, requestedBytes=-1):
        """Read incoming data from the target stream and decrypt it.

        """
        ciphertext = super(Cryptor, self).read(requestedBytes)

        return self.decrypt(ciphertext)

    def write(self, data):
        """Encrypt outgoing data and then write it to the target stream.

        """
        data = self.encrypt(data)
        return super(Cryptor, self).write(data)

{'fraction_non_alphanumeric': 0.08519637462235649, 'fraction_numerical': 0.0006042296072507553, 'mean_word_length': 2.8422273781902554, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1054405', 'n_tokens_mistral': 459, 'n_tokens_neox': 423, 'n_words': 143}