# Path: ndb/tasklets.py
# _CALLBACK_KEY = '__CALLBACK__'
#   IDLE = apiproxy_rpc.RPC.IDLE  # Not yet running (unused)
#   RUNNING = apiproxy_rpc.RPC.RUNNING  # Not yet completed.
#   FINISHING = apiproxy_rpc.RPC.FINISHING  # Completed.
# _CONTEXT_KEY = '__CONTEXT__'
# _DATASTORE_APP_ID_ENV = 'DATASTORE_APP_ID'
# _DATASTORE_PROJECT_ID_ENV = 'DATASTORE_PROJECT_ID'
# _DATASTORE_ADDITIONAL_APP_IDS_ENV = 'DATASTORE_ADDITIONAL_APP_IDS'
# _DATASTORE_USE_PROJECT_ID_AS_APP_ID_ENV = 'DATASTORE_USE_PROJECT_ID_AS_APP_ID'
# def _is_generator(obj):
#   def __init__(self):
#   def set_context(self, ctx):
#   def add_generator(self, gen):
#   def add_pending(self, fut):
#   def remove_pending(self, fut, status='success'):
#   def clear_all_generators(self):
#   def clear_all_pending(self):
#   def dump_all_pending(self, verbose=False):
#   def reset(self, unused_req_id):
# def add_flow_exception(exc):
# def _init_flow_exceptions():
#   def __init__(self, info=None):
#   def _reset(self):
#   def __repr__(self):
#   def dump(self):
#   def dump_stack(self):
#   def add_callback(self, callback, *args, **kwds):
#   def add_immediate_callback(self, callback, *args, **kwds):
#   def set_result(self, result):
#   def set_exception(self, exc, tb=None):
#   def done(self):
#   def state(self):
#   def wait(self):
#   def get_exception(self):
#   def get_traceback(self):
#   def check_success(self):
#   def get_result(self):
#   def wait_any(cls, futures):
#   def wait_all(cls, futures):
#   def _help_tasklet_along(self, ns, ds_conn, gen, val=None, exc=None, tb=None):
#   def _on_rpc_completion(self, rpc, ns, ds_conn, gen):
#   def _on_future_completion(self, future, ns, ds_conn, gen):
# def sleep(dt):
#   def __init__(self, info=None):
#   def __repr__(self):
#   def complete(self):
#   def set_exception(self, exc, tb=None):
#   def _finish(self):
#   def putq(self, value):
#   def add_dependent(self, fut):
#   def _signal_dependent_done(self, fut):
#   def __init__(self, info=None):
#   def complete(self):
#   def set_exception(self, exc, tb=None):
#   def putq(self, value):
#   def add_dependent(self, fut):
#   def _signal_dependent_done(self, fut):
#   def _mark_finished(self):
#   def getq(self):
#   def _pass_eof(self, fut):
#   def _pass_result(self, fut, exc, tb, val):
#   def __init__(self, info=None):
#   def complete(self):
#   def set_exception(self, exc, tb=None):
#   def putq(self, value):
#   def add_dependent(self, fut):
#   def getq(self):
# def _transfer_result(fut1, fut2):
#   def __init__(self, reducer, info=None, batch_size=20):
#   def complete(self):
#   def set_exception(self, exc, tb=None):
#   def putq(self, value):
#   def add_dependent(self, fut):
#   def _internal_add_dependent(self, fut):
#   def _signal_dependent_done(self, fut):
#   def _mark_finished(self):
# def get_return_value(err):
# def tasklet(func):
#   def tasklet_wrapper(*args, **kwds):
# def synctasklet(func):
#   def synctasklet_wrapper(*args, **kwds):
# def toplevel(func):
#   def add_context_wrapper(*args, **kwds):
# def get_context():
# def make_default_context():
# def make_context(conn=None, config=None):
# def _make_cloud_datastore_context(app_id, external_app_ids=()):
# def set_context(new_context):
#   def MakeSyncCall(self, service, call, request, response):
#   def CreateRPC(self):
# class _State(utils.threading_local):
# class Future(object):
# class MultiFuture(Future):
# class QueueFuture(Future):
# class SerialQueueFuture(Future):
# class ReducingFuture(Future):
# class _ThrowingStub(object):
# 
# Path: ndb/google_imports.py
#   GOOGLE_PACKAGE_PATH = set(google.__path__)
#   GOOGLE_PACKAGE_PATH = None
# def set_appengine_imports():


import atexit
import code
import readline
import os
import sys
import ndb
from ndb import tasklets
from ndb.google_imports import datastore_pbs
# Copyright 2015 The ndb Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



HISTORY_PATH = os.path.expanduser('~/.ndb_shell_history')

def shell():

  if (not os.environ.get('DATASTORE_APP_ID', None)
      and not os.environ.get('DATASTORE_PROJECT_ID', None)):
    raise ValueError('Must set either DATASTORE_APP_ID or DATASTORE_PROJECT_ID'
                     ' environment variable.')

  ndb.get_context().set_memcache_policy(False)
  ndb.get_context().set_cache_policy(False)

  # ndb will set the application ID.
  application_id = os.environ['APPLICATION_ID']

# Path: ndb/tasklets.py
# _CALLBACK_KEY = '__CALLBACK__'
#   IDLE = apiproxy_rpc.RPC.IDLE  # Not yet running (unused)
#   RUNNING = apiproxy_rpc.RPC.RUNNING  # Not yet completed.
#   FINISHING = apiproxy_rpc.RPC.FINISHING  # Completed.
# _CONTEXT_KEY = '__CONTEXT__'
# _DATASTORE_APP_ID_ENV = 'DATASTORE_APP_ID'
# _DATASTORE_PROJECT_ID_ENV = 'DATASTORE_PROJECT_ID'
# _DATASTORE_ADDITIONAL_APP_IDS_ENV = 'DATASTORE_ADDITIONAL_APP_IDS'
# _DATASTORE_USE_PROJECT_ID_AS_APP_ID_ENV = 'DATASTORE_USE_PROJECT_ID_AS_APP_ID'
# def _is_generator(obj):
#   def __init__(self):
#   def set_context(self, ctx):
#   def add_generator(self, gen):
#   def add_pending(self, fut):
#   def remove_pending(self, fut, status='success'):
#   def clear_all_generators(self):
#   def clear_all_pending(self):
#   def dump_all_pending(self, verbose=False):
#   def reset(self, unused_req_id):
# def add_flow_exception(exc):
# def _init_flow_exceptions():
#   def __init__(self, info=None):
#   def _reset(self):
#   def __repr__(self):
#   def dump(self):
#   def dump_stack(self):
#   def add_callback(self, callback, *args, **kwds):
#   def add_immediate_callback(self, callback, *args, **kwds):
#   def set_result(self, result):
#   def set_exception(self, exc, tb=None):
#   def done(self):
#   def state(self):
#   def wait(self):
#   def get_exception(self):
#   def get_traceback(self):
#   def check_success(self):
#   def get_result(self):
#   def wait_any(cls, futures):
#   def wait_all(cls, futures):
#   def _help_tasklet_along(self, ns, ds_conn, gen, val=None, exc=None, tb=None):
#   def _on_rpc_completion(self, rpc, ns, ds_conn, gen):
#   def _on_future_completion(self, future, ns, ds_conn, gen):
# def sleep(dt):
#   def __init__(self, info=None):
#   def __repr__(self):
#   def complete(self):
#   def set_exception(self, exc, tb=None):
#   def _finish(self):
#   def putq(self, value):
#   def add_dependent(self, fut):
#   def _signal_dependent_done(self, fut):
#   def __init__(self, info=None):
#   def complete(self):
#   def set_exception(self, exc, tb=None):
#   def putq(self, value):
#   def add_dependent(self, fut):
#   def _signal_dependent_done(self, fut):
#   def _mark_finished(self):
#   def getq(self):
#   def _pass_eof(self, fut):
#   def _pass_result(self, fut, exc, tb, val):
#   def __init__(self, info=None):
#   def complete(self):
#   def set_exception(self, exc, tb=None):
#   def putq(self, value):
#   def add_dependent(self, fut):
#   def getq(self):
# def _transfer_result(fut1, fut2):
#   def __init__(self, reducer, info=None, batch_size=20):
#   def complete(self):
#   def set_exception(self, exc, tb=None):
#   def putq(self, value):
#   def add_dependent(self, fut):
#   def _internal_add_dependent(self, fut):
#   def _signal_dependent_done(self, fut):
#   def _mark_finished(self):
# def get_return_value(err):
# def tasklet(func):
#   def tasklet_wrapper(*args, **kwds):
# def synctasklet(func):
#   def synctasklet_wrapper(*args, **kwds):
# def toplevel(func):
#   def add_context_wrapper(*args, **kwds):
# def get_context():
# def make_default_context():
# def make_context(conn=None, config=None):
# def _make_cloud_datastore_context(app_id, external_app_ids=()):
# def set_context(new_context):
#   def MakeSyncCall(self, service, call, request, response):
#   def CreateRPC(self):
# class _State(utils.threading_local):
# class Future(object):
# class MultiFuture(Future):
# class QueueFuture(Future):
# class SerialQueueFuture(Future):
# class ReducingFuture(Future):
# class _ThrowingStub(object):
# 
# Path: ndb/google_imports.py
#   GOOGLE_PACKAGE_PATH = set(google.__path__)
#   GOOGLE_PACKAGE_PATH = None
# def set_appengine_imports():


# Path: demo/shell.py
import atexit
import code
import readline
import os
import sys
import ndb
from ndb import tasklets
from ndb.google_imports import datastore_pbs

# Copyright 2015 The ndb Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



HISTORY_PATH = os.path.expanduser('~/.ndb_shell_history')

def shell():

  if (not os.environ.get('DATASTORE_APP_ID', None)
      and not os.environ.get('DATASTORE_PROJECT_ID', None)):
    raise ValueError('Must set either DATASTORE_APP_ID or DATASTORE_PROJECT_ID'
                     ' environment variable.')

  ndb.get_context().set_memcache_policy(False)
  ndb.get_context().set_cache_policy(False)

  # ndb will set the application ID.
  application_id = os.environ['APPLICATION_ID']

  id_resolver = datastore_pbs.IdResolver((application_id,))