<commit_before>from __future__ import absolute_import
from simpleeval import InvalidExpression
from corehq.apps.locations.document_store import LOCATION_DOC_TYPE
from corehq.apps.userreports.const import XFORM_CACHE_KEY_PREFIX
from corehq.apps.userreports.document_stores import get_document_store
from corehq.apps.userreports.exceptions import BadSpecError
from corehq.apps.users.models import CommCareUser
from corehq.form_processor.interfaces.dbaccessors import CaseAccessors
from corehq.util.couch import get_db_by_doc_type
from dimagi.ext.jsonobject import JsonObject, StringProperty, ListProperty, DictProperty
from jsonobject.base_properties import DefaultProperty
from corehq.apps.userreports.expressions.getters import transform_from_datatype, safe_recursive_lookup
from corehq.apps.userreports.indicators.specs import DataTypeProperty
from corehq.apps.userreports.specs import TypeProperty, EvaluationContext
from corehq.form_processor.interfaces.processor import FormProcessorInterface
from pillowtop.dao.exceptions import DocumentNotFoundError
from .utils import eval_statements
import six


class IdentityExpressionSpec(JsonObject):
    type = TypeProperty('identity')

    def __call__(self, item, context=None):
        return item


class IterationNumberExpressionSpec(JsonObject):
    type = TypeProperty('base_iteration_number')

    def __call__(self, item, context=None):
        return context.iteration


class ConstantGetterSpec(JsonObject):
    type = TypeProperty('constant')
    constant = DefaultProperty()

    @classmethod
    def wrap(self, obj):
        if 'constant' not in obj:
            raise BadSpecError('"constant" property is required!')
        return super(ConstantGetterSpec, self).wrap(obj)<commit_msg>better imports<commit_after>from __future__ import absolute_import
from jsonobject.base_properties import DefaultProperty
from simpleeval import InvalidExpression
import six

from corehq.apps.locations.document_store import LOCATION_DOC_TYPE
from corehq.apps.userreports.const import XFORM_CACHE_KEY_PREFIX
from corehq.apps.userreports.document_stores import get_document_store
from corehq.apps.userreports.exceptions import BadSpecError
from corehq.apps.users.models import CommCareUser
from corehq.form_processor.interfaces.dbaccessors import CaseAccessors
from corehq.util.couch import get_db_by_doc_type
from corehq.apps.userreports.expressions.getters import transform_from_datatype, safe_recursive_lookup
from corehq.apps.userreports.indicators.specs import DataTypeProperty
from corehq.apps.userreports.specs import TypeProperty, EvaluationContext
from corehq.form_processor.interfaces.processor import FormProcessorInterface
from dimagi.ext.jsonobject import JsonObject, StringProperty, ListProperty, DictProperty
from pillowtop.dao.exceptions import DocumentNotFoundError
from .utils import eval_statements


class IdentityExpressionSpec(JsonObject):
    type = TypeProperty('identity')

    def __call__(self, item, context=None):
        return item


class IterationNumberExpressionSpec(JsonObject):
    type = TypeProperty('base_iteration_number')

    def __call__(self, item, context=None):
        return context.iteration


class ConstantGetterSpec(JsonObject):
    type = TypeProperty('constant')
    constant = DefaultProperty()

    @classmethod
    def wrap(self, obj):
        if 'constant' not in obj:
            raise BadSpecError('"constant" property is required!')
        return super(ConstantGetterSpec, self).wrap(obj)
{'fraction_non_alphanumeric': 0.06239267315397825, 'fraction_numerical': 0.0, 'mean_word_length': 6.004008016032064, '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': '1877250', 'n_tokens_mistral': 974, 'n_tokens_neox': 939, 'n_words': 236}