<commit_before>"""
Created on Apr 23, 2013.
"""
from StringIO import StringIO
from everest.interfaces import IUserMessageNotifier
from everest.representers.base import ResourceRepresenter
from everest.resources.utils import get_member_class
from pyramid.httpexceptions import HTTPBadRequest
from pyramid.threadlocal import get_current_registry
import logging
from thelma.mime import BioMicroLabXl20TextOutputMime
from thelma.models.utils import get_current_user
from thelma.automation.tools.worklists.tubehandler import XL20Executor

__docformat__ = 'reStructuredText en'
__all__ = ['Xl20OutputRepresenter',
           ]


class ExternalParserResourceRepresenter(ResourceRepresenter):
    """
    Representer that uses an external parser to convert incoming
    representations to resources.
    """
    content_type = None
    parser_factory = None
    def __init__(self, resource_class, parser_factory):
        """
        :param resource_class: the class of the resource to generate from
            incoming representations
        :param parser_factory: a callable that generates a new parser. All
            options set with the :meth:`configure` method are passed to the
            factory call.
        """
        ResourceRepresenter.__init__(self, resource_class)
        self.__parser_factory = parser_factory
        self.__parser_options = {}

    @classmethod
    def create_from_resource(cls, rc):
        return cls(get_member_class(rc), cls.parser_factory)

    def from_stream(self, stream):
        data_el = self.data_from_stream(stream)
        return self.resource_from_data(data_el)
<commit_msg>Reflecting an everest change in the representer factory method name.<commit_after>"""
Created on Apr 23, 2013.
"""
from StringIO import StringIO
from everest.interfaces import IUserMessageNotifier
from everest.representers.base import ResourceRepresenter
from everest.resources.utils import get_member_class
from pyramid.httpexceptions import HTTPBadRequest
from pyramid.threadlocal import get_current_registry
import logging
from thelma.mime import BioMicroLabXl20TextOutputMime
from thelma.models.utils import get_current_user
from thelma.automation.tools.worklists.tubehandler import XL20Executor

__docformat__ = 'reStructuredText en'
__all__ = ['Xl20OutputRepresenter',
           ]


class ExternalParserResourceRepresenter(ResourceRepresenter):
    """
    Representer that uses an external parser to convert incoming
    representations to resources.
    """
    content_type = None
    parser_factory = None
    def __init__(self, resource_class, parser_factory):
        """
        :param resource_class: the class of the resource to generate from
            incoming representations
        :param parser_factory: a callable that generates a new parser. All
            options set with the :meth:`configure` method are passed to the
            factory call.
        """
        ResourceRepresenter.__init__(self, resource_class)
        self.__parser_factory = parser_factory
        self.__parser_options = {}

    @classmethod
    def create_from_resource_class(cls, resource_class):
        return cls(get_member_class(resource_class), cls.parser_factory)

    def from_stream(self, stream):
        data_el = self.data_from_stream(stream)
        return self.resource_from_data(data_el)

{'fraction_non_alphanumeric': 0.0598136459272618, 'fraction_numerical': 0.007213706041478809, 'mean_word_length': 3.901325478645066, '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': '2722456', 'n_tokens_mistral': 922, 'n_tokens_neox': 869, 'n_words': 257}