# 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'


import re
  import sys, os
import json
import scope
import lookup
import pprint
import cgi
  import cmdline
from pymql.log import LOG, log_util, pprintlog, dumplog
from pymql.error import EmptyResult
from qprim import QueryPrimitive
from utils import (element, elements, dict_recurse, valid_relname, follow_path,
                   is_direct_pointer, valid_precompiled_sort, ReadMode,
                   WriteMode, PrepareMode, CheckMode, QueryDict, QueryList,
                   ResultDict, Missing)
from error import MQLResultError, MQLInternalError, MQLInternalParseError, MQLAccessError, MQLGraphError
from env import Varenv
      elif key[1:] in QueryPrimitive.pointers and is_direct_pointer(item[key]):
        if key[0] == '@':
          node.add_pointer(key[1:], item[key].node)
          self.link_query_primitives(item[key], varenv, mode)
        elif key[0] == ':' and link is not Missing:
          link.add_pointer(key[1:], item[key].node)
          self.link_query_primitives(item[key], varenv, mode)
        else:
          raise MQLInternalParseError(
              item, 'Invalid use of a direct slot for %(key)s', key=key)

  def make_ordered_query_primitives(self, qlist, varenv, mode):
    # note that qlist is the QueryList object at the point where we have the index statements
    # in clauses. It represents them as a group, not a particular individual one...

    # XXX There are a lot of questions about how strict we can/should be with what
    # is seen in an ordered set. Right now we enforce
    # - same typeguid
    # - same direction
    # which make things sane. For ease of understanding and use we also enforce
    # - indexes must be a permutation of 1..N (ie nothing missing, no duplicates, starts at 1)
    # we do not enforce
    # - everything has to have an index (ie you can order only half the list)

    if len(qlist) == 0:
      # we should have caught this earlier
      raise MQLInternalError(
          qlist.parent_clause, "Can't order an empty list", key=qlist.key)

    if qlist.is_root:

# 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/lojson.py
import re
  import sys, os
import json
import scope
import lookup
import pprint
import cgi
  import cmdline
from pymql.log import LOG, log_util, pprintlog, dumplog
from pymql.error import EmptyResult
from qprim import QueryPrimitive
from utils import (element, elements, dict_recurse, valid_relname, follow_path,
                   is_direct_pointer, valid_precompiled_sort, ReadMode,
                   WriteMode, PrepareMode, CheckMode, QueryDict, QueryList,
                   ResultDict, Missing)
from error import MQLResultError, MQLInternalError, MQLInternalParseError, MQLAccessError, MQLGraphError
from env import Varenv

      elif key[1:] in QueryPrimitive.pointers and is_direct_pointer(item[key]):
        if key[0] == '@':
          node.add_pointer(key[1:], item[key].node)
          self.link_query_primitives(item[key], varenv, mode)
        elif key[0] == ':' and link is not Missing:
          link.add_pointer(key[1:], item[key].node)
          self.link_query_primitives(item[key], varenv, mode)
        else:
          raise MQLInternalParseError(
              item, 'Invalid use of a direct slot for %(key)s', key=key)

  def make_ordered_query_primitives(self, qlist, varenv, mode):
    # note that qlist is the QueryList object at the point where we have the index statements
    # in clauses. It represents them as a group, not a particular individual one...

    # XXX There are a lot of questions about how strict we can/should be with what
    # is seen in an ordered set. Right now we enforce
    # - same typeguid
    # - same direction
    # which make things sane. For ease of understanding and use we also enforce
    # - indexes must be a permutation of 1..N (ie nothing missing, no duplicates, starts at 1)
    # we do not enforce
    # - everything has to have an index (ie you can order only half the list)

    if len(qlist) == 0:
      # we should have caught this earlier
      raise MQLInternalError(
          qlist.parent_clause, "Can't order an empty list", key=qlist.key)

    if qlist.is_root:

      raise MQLInternalParseError(qlist, "Can't order the root of a query")