<commit_before>import json
import logging

# Our imports
from emission.core.get_database import get_profile_db, get_pending_signup_db, get_uuid_db

defaultCarFootprint = 278.0/1609
defaultMpg = 8.91/(1.6093 * defaultCarFootprint) # Should be roughly 32

class User:
  def __init__(self, uuid):
    self.uuid = uuid
    # TODO: Read this from a file instead
    self.defaultSettings = {
      'result_url': 'https://e-mission.eecs.berkeley.edu/compare'
    }

  @staticmethod
  def isRegistered(userEmail):
    email2UUID = get_uuid_db().find_one({'user_email': userEmail})
    if email2UUID is None:
      return False
    else:
      return True

  @staticmethod
  def fromEmail(userEmail):
    email2UUID = get_uuid_db().find_one({'user_email': userEmail})
    if email2UUID is None:
      return None
    user = User(email2UUID['uuid'])
    user.__email = userEmail
    return user

  @staticmethod
  def fromUUID(user_uuid):
    user = User(user_uuid)
    uuid2Email = get_uuid_db().find_one({'uuid': user_uuid})
    user.__email = uuid2Email['user_email']
    return user

  def getProfile(self):
    return get_profile_db().find_one({'user_id': self.uuid})

  # In the real system, we should always have a profile for the user. But
  # during unit tests, and durig analysis, that it not always true. Let us fail
  # more gracefully if no profile is present
  def getStudy(self):
    if self.getProfile() != None:
        return self.getProfile()['study_list']
    else:<commit_msg>Modify changes to work with old/obsolete tests<commit_after>import json
import logging

# Our imports
from emission.core.get_database import get_profile_db, get_pending_signup_db, get_uuid_db

defaultCarFootprint = 278.0/1609
defaultMpg = 8.91/(1.6093 * defaultCarFootprint) # Should be roughly 32

class User:
  def __init__(self, uuid):
    self.uuid = uuid
    # TODO: Read this from a file instead
    self.defaultSettings = {
      'result_url': 'https://e-mission.eecs.berkeley.edu/compare'
    }

  @staticmethod
  def isRegistered(userEmail):
    email2UUID = get_uuid_db().find_one({'user_email': userEmail})
    if email2UUID is None:
      return False
    else:
      return True

  @staticmethod
  def fromEmail(userEmail):
    email2UUID = get_uuid_db().find_one({'user_email': userEmail})
    if email2UUID is None:
      return None
    user = User(email2UUID['uuid'])
    user.__email = userEmail
    return user

  @staticmethod
  def fromUUID(user_uuid):
    user = User(user_uuid)
    uuid2Email = get_uuid_db().find_one({'uuid': user_uuid})
    # Remove once we remove obsolete code/tests that doesn't create an email ->
    # uuid mapping
    if 'user_email' in uuid2Email:
      user.__email = uuid2Email['user_email']
    return user

  def getProfile(self):
    return get_profile_db().find_one({'user_id': self.uuid})

  # In the real system, we should always have a profile for the user. But
  # during unit tests, and durig analysis, that it not always true. Let us fail
  # more gracefully if no profile is present
  def getStudy(self):
    if self.getProfile() != None:
        return self.getProfile()['study_list']
    else:
{'fraction_non_alphanumeric': 0.09863188036907414, 'fraction_numerical': 0.016226535157492842, 'mean_word_length': 3.623529411764706, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 2, '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': '5805149', 'n_tokens_mistral': 1029, 'n_tokens_neox': 1012, 'n_words': 284}