# 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 grquoting import quote, unquote
from itertools import chain
from utils import (valid_value_op, valid_timestamp_op, valid_timestamp,
                   valid_history_op, valid_guid, ReadMode, WriteMode,
                   PrepareMode, CheckMode, Missing, ResultDict, incr_subseq)
from error import (MQLResultError, MQLInternalError, MQLInternalParseError,
                   MQLValueAlreadyInUseError, MQLTooManyValuesForUniqueQuery)
from pymql.log import LOG
    # note that this overrides the direct result set above. This
    # is intentional.
    for mychild in self.children:
      if len(result[n]) == 1:
        resultd[self.prefix + mychild] = getattr(self, mychild).create_results(
            result[n][0], ResultDict(), mode)
      elif len(result[n]) == 0:
        resultd[self.prefix + mychild] = None
      else:
        guids = [('#' + x[0]) for x in result[n]]
        raise MQLInternalError(
            self.query,
            'Direct children must have at most one result, got %(count)d',
            count=len(result[n]),
            key=mychild,
            guids=guids)

      n += 1

    # and the contents - all links to other prims - links never have contents, only pointers and children
    for mycontent in self.contents:
      if mycontent.query_unique:
        if len(result[n]) == 1:
          resultd[mycontent.query_key] = mycontent.create_results(
              result[n][0], ResultDict(), mode)
        elif len(result[n]) == 0:
          resultd[mycontent.query_key] = None
        else:
          # nasty but quick way to get useful info - we know that the guid is always the first part element of the result.
          guids = [('#' + x[0]) for x in result[n]]

# 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/qprim.py
from grquoting import quote, unquote
from itertools import chain
from utils import (valid_value_op, valid_timestamp_op, valid_timestamp,
                   valid_history_op, valid_guid, ReadMode, WriteMode,
                   PrepareMode, CheckMode, Missing, ResultDict, incr_subseq)
from error import (MQLResultError, MQLInternalError, MQLInternalParseError,
                   MQLValueAlreadyInUseError, MQLTooManyValuesForUniqueQuery)
from pymql.log import LOG

    # note that this overrides the direct result set above. This
    # is intentional.
    for mychild in self.children:
      if len(result[n]) == 1:
        resultd[self.prefix + mychild] = getattr(self, mychild).create_results(
            result[n][0], ResultDict(), mode)
      elif len(result[n]) == 0:
        resultd[self.prefix + mychild] = None
      else:
        guids = [('#' + x[0]) for x in result[n]]
        raise MQLInternalError(
            self.query,
            'Direct children must have at most one result, got %(count)d',
            count=len(result[n]),
            key=mychild,
            guids=guids)

      n += 1

    # and the contents - all links to other prims - links never have contents, only pointers and children
    for mycontent in self.contents:
      if mycontent.query_unique:
        if len(result[n]) == 1:
          resultd[mycontent.query_key] = mycontent.create_results(
              result[n][0], ResultDict(), mode)
        elif len(result[n]) == 0:
          resultd[mycontent.query_key] = None
        else:
          # nasty but quick way to get useful info - we know that the guid is always the first part element of the result.
          guids = [('#' + x[0]) for x in result[n]]

          raise MQLTooManyValuesForUniqueQuery(