# Path: error.py
# def is_valid_HTTP_code(code):
# def get_HTTP_err(code):
#   def __init__(self,
#                msg,
#                http_code=400,
#                app_code=DEF_ME_CODE,
#                inner_exc=None,
#                **kwds):
#   def gen_msgs(self, **kwds):
#   def get_err_dict(self):
#   def __str__(self):
#   def __init__(self,
#                msg,
#                http_code=500,
#                app_code=ParameterizedError.DEF_ME_CODE,
#                inner_exc=None,
#                **kwds):
#   def __init__(self, msg=None, *args, **kwds):
# class ParameterizedError(Exception):
# class NetworkAddressError(ParameterizedError):
# class ContentLoadError(ParameterizedError):
# class TypeVerifyError(ParameterizedError):
# class EmailError(ParameterizedError):
# class SubscriptionError(ParameterizedError):
# class MSSError(ParameterizedError):
# class UserLookupError(ParameterizedError):
# class UserAuthError(ParameterizedError):
# class BlobError(ParameterizedError):
# class BLOBClientError(ParameterizedError):
# class RelevanceError(ParameterizedError):
# class TextSearchError(ParameterizedError):
# class AutocompleteError(ParameterizedError):
# class EmptyResult(ParameterizedError):
# class GraphConnectionError(ParameterizedError):
# class FormattingError(ParameterizedError):
# class SessionError(ParameterizedError):
# class ConfigError(ParameterizedError):
# class SanitizationError(ParameterizedError):
# class BlurbError(ParameterizedError):
# class DomainOperationError(ParameterizedError):
# class GenericRuntimeError(ParameterizedError):
# class OAuthDisabledError(ParameterizedError):
# class RecaptchaError(ParameterizedError):
# class ReadOnlyDatabaseError(ParameterizedError):
#   DEF_PFX = '/api/status/error'
#   DEF_ME_CODE = '/unknown/unknown'


from utils import valid_idname, valid_guid
from error import MQLParseError, MQLInternalError
from namespace import NameMap
from pymql.error import EmptyResult
from pymql.log import LOG
import mid
  def lookup_id_internal(self, guid, varenv):
    if guid is None:
      return None

    elif guid in self.guids:
      return self.guids[guid]

    else:
      found_id = self.lookup_id_query(guid, varenv)
      self.guids[guid] = found_id
      return found_id

  # eek. see https://wiki.metaweb.com/index.php/Machine_IDs
  def lookup_guids_of_mids(self, mid_list, varenv):
    ask_list = set()
    result = {}
    rev = {}
    # arithmetically compute guids
    for m in mid_list:
      try:
        guid = "#" + mid.to_guid(m)
        ask_list.add(guid)
        # store the whole list here, down below we'll just
        # overwrite the things we got back.
        result[m] = guid  #self.internal_guid_to_id(guid)
        # i need to go back + forth.
        rev[guid] = m
      except (mid.InvalidMIDVersion, mid.InvalidMID) as e:
        result[m] = False
      except (mid.InvalidMunch) as e:

# Path: error.py
# def is_valid_HTTP_code(code):
# def get_HTTP_err(code):
#   def __init__(self,
#                msg,
#                http_code=400,
#                app_code=DEF_ME_CODE,
#                inner_exc=None,
#                **kwds):
#   def gen_msgs(self, **kwds):
#   def get_err_dict(self):
#   def __str__(self):
#   def __init__(self,
#                msg,
#                http_code=500,
#                app_code=ParameterizedError.DEF_ME_CODE,
#                inner_exc=None,
#                **kwds):
#   def __init__(self, msg=None, *args, **kwds):
# class ParameterizedError(Exception):
# class NetworkAddressError(ParameterizedError):
# class ContentLoadError(ParameterizedError):
# class TypeVerifyError(ParameterizedError):
# class EmailError(ParameterizedError):
# class SubscriptionError(ParameterizedError):
# class MSSError(ParameterizedError):
# class UserLookupError(ParameterizedError):
# class UserAuthError(ParameterizedError):
# class BlobError(ParameterizedError):
# class BLOBClientError(ParameterizedError):
# class RelevanceError(ParameterizedError):
# class TextSearchError(ParameterizedError):
# class AutocompleteError(ParameterizedError):
# class EmptyResult(ParameterizedError):
# class GraphConnectionError(ParameterizedError):
# class FormattingError(ParameterizedError):
# class SessionError(ParameterizedError):
# class ConfigError(ParameterizedError):
# class SanitizationError(ParameterizedError):
# class BlurbError(ParameterizedError):
# class DomainOperationError(ParameterizedError):
# class GenericRuntimeError(ParameterizedError):
# class OAuthDisabledError(ParameterizedError):
# class RecaptchaError(ParameterizedError):
# class ReadOnlyDatabaseError(ParameterizedError):
#   DEF_PFX = '/api/status/error'
#   DEF_ME_CODE = '/unknown/unknown'


# Path: mql/lookup.py
from utils import valid_idname, valid_guid
from error import MQLParseError, MQLInternalError
from namespace import NameMap
from pymql.error import EmptyResult
from pymql.log import LOG
import mid

  def lookup_id_internal(self, guid, varenv):
    if guid is None:
      return None

    elif guid in self.guids:
      return self.guids[guid]

    else:
      found_id = self.lookup_id_query(guid, varenv)
      self.guids[guid] = found_id
      return found_id

  # eek. see https://wiki.metaweb.com/index.php/Machine_IDs
  def lookup_guids_of_mids(self, mid_list, varenv):
    ask_list = set()
    result = {}
    rev = {}
    # arithmetically compute guids
    for m in mid_list:
      try:
        guid = "#" + mid.to_guid(m)
        ask_list.add(guid)
        # store the whole list here, down below we'll just
        # overwrite the things we got back.
        result[m] = guid  #self.internal_guid_to_id(guid)
        # i need to go back + forth.
        rev[guid] = m
      except (mid.InvalidMIDVersion, mid.InvalidMID) as e:
        result[m] = False
      except (mid.InvalidMunch) as e:

        raise MQLParseError(