<commit_before>from __future__ import absolute_import
from collections import defaultdict, namedtuple
from copy import copy
from datetime import datetime
import architect
import uuid
import json
from couchdbkit.exceptions import ResourceConflict, ResourceNotFound
from casexml.apps.phone.exceptions import IncompatibleSyncLogType, MissingSyncLog
from corehq.toggles import LEGACY_SYNC_SUPPORT
from corehq.util.global_request import get_request_domain
from corehq.util.soft_assert import soft_assert
from corehq.toggles import ENABLE_LOADTEST_USERS
from corehq.apps.domain.models import Domain
from dimagi.ext.couchdbkit import *
from django.db import models
from django.contrib.postgres.fields import JSONField
from django.core.exceptions import ValidationError
from memoized import memoized
from dimagi.utils.mixins import UnicodeMixIn
from dimagi.utils.couch import LooselyEqualDocumentSchema
from casexml.apps.case import const
from casexml.apps.case.sharedmodels import CommCareCaseIndex, IndexHoldingMixIn
from casexml.apps.phone.checksum import Checksum, CaseStateHash
from casexml.apps.phone.change_publishers import publish_synclog_saved
import logging
import six


def _get_logger():
    # for some strange reason if you define logger the normal way it gets silenced in tests.
    # this is a hacky workaround to that.
    return logging.getLogger(__name__)


class OTARestoreUser(object):
    """
    This is the OTA restore user's interface that's used for OTA restore to properly
    find cases and generate the user XML for both a web user and mobile user.<commit_msg>import<commit_after>from __future__ import absolute_import
from collections import defaultdict, namedtuple
from copy import copy
from datetime import datetime
import architect
import uuid
import json
from couchdbkit.exceptions import ResourceConflict, ResourceNotFound
from casexml.apps.phone.exceptions import IncompatibleSyncLogType, MissingSyncLog
from corehq.toggles import LEGACY_SYNC_SUPPORT
from corehq.util.global_request import get_request_domain
from corehq.util.soft_assert import soft_assert
from corehq.toggles import ENABLE_LOADTEST_USERS
from corehq.apps.domain.models import Domain
from dimagi.ext.couchdbkit import *
from django.db import models
from django.contrib.postgres.fields import JSONField
from django.core.exceptions import ValidationError
from memoized import memoized
from dimagi.utils.mixins import UnicodeMixIn
from dimagi.utils.couch import LooselyEqualDocumentSchema
from dimagi.utils.logging import notify_exception
from casexml.apps.case import const
from casexml.apps.case.sharedmodels import CommCareCaseIndex, IndexHoldingMixIn
from casexml.apps.phone.checksum import Checksum, CaseStateHash
from casexml.apps.phone.change_publishers import publish_synclog_saved
import logging
import six


def _get_logger():
    # for some strange reason if you define logger the normal way it gets silenced in tests.
    # this is a hacky workaround to that.
    return logging.getLogger(__name__)


class OTARestoreUser(object):
    """
    This is the OTA restore user's interface that's used for OTA restore to properly
    find cases and generate the user XML for both a web user and mobile user.
{'fraction_non_alphanumeric': 0.0405616224648986, 'fraction_numerical': 0.0, 'mean_word_length': 5.835820895522388, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '3625070', 'n_tokens_mistral': 876, 'n_tokens_neox': 855, 'n_words': 323}