# Path: pyke/knowledge_engine.py
#     class chain(object):
# class CanNotProve(StandardError):
# class engine(object):
#         def __new__(cls, *args):
#         def from_iterable(i):
#     def __init__(self, *search_paths, **kws):
#     def _create_target_pkg(self, path, target_pkgs):
#     def get_ask_module(self):
#     def reset(self):
#     def get_kb(self, kb_name, _new_class = None):
#     def get_rb(self, rb_name):
#     def get_create(self, rb_name, parent = None, exclude_list = ()):
#     def get_ke(self, kb_name, entity_name):
#     def add_universal_fact(self, kb_name, fact_name, args):
#     def add_case_specific_fact(self, kb_name, fact_name, args):
#     def assert_(self, kb_name, entity_name, args):
#     def activate(self, *rb_names):
#     def lookup(self, kb_name, entity_name, pat_context, patterns):
#     def prove_goal(self, goal_str, **args):
#     def prove_1_goal(self, goal_str, **args):
#     def prove(self, kb_name, entity_name, pat_context, patterns):
#     def prove_n(self, kb_name, entity_name, fixed_args = (), num_returns = 0):
#         def gen():
#     def prove_1(self, kb_name, entity_name, fixed_args = (), num_returns = 0):
#     def print_stats(self, f = sys.stdout):
#     def trace(self, rb_name, rule_name):
#     def untrace(self, rb_name, rule_name):
# def _get_target_pkg(target_name):
# def _pythonify_path(path):
# def _is_package_dir(path):
# def in_sys_path(path):
# 
# Path: pyke/krb_traceback.py
# def print_tb(traceback, limit=None, file=None):
# def print_exception(type, value, traceback, limit=None, file=None):
# def print_exc(limit=None, file=None):
# def format_exc(limit=None):
# def print_last(limit=None, file=None):
# def print_stack(f=None, limit=None, file=None):
# def extract_tb(tb, limit=None):
# def extract_stack(f=None, limit=None):
# def format_exception(type, value, traceback, limit=None):
# def format_tb(tb, limit=None):
# def format_stack(f=None, limit=None):
# def convert_lineno(module, lineno):
# def convert_tb(extracted_tb):


import sys
import os, os.path
import sqlgen
from pyke import knowledge_engine, krb_traceback
    try:
        no_vars, plan = \
            Engine.prove_1_goal('web.process($starting_tables, $template_name)',
                                starting_tables=starting_tables,
                                template_name=template_name)
    except:
        traceback = krb_traceback.format_exc(100)
        return None, traceback
    return plan, None

Plans_cache = {}

def wsgi_app(environ, start_response):
    global Plans_cache

    # Parse the path:
    components = environ["PATH_INFO"].lstrip('/').split('/')
    template_name = os.path.join(Web_framework_dir, components[-1])
    starting_tables = []
    starting_keys = {}
    for i in range(0, len(components) - 1, 2):
        starting_tables.append(components[i])
        starting_keys[components[i]] = int(components[i + 1])
    # Convert to tuple so that it can be used as a dict key and sort so
    # different orders compare equal.
    starting_tables = tuple(sorted(starting_tables))

    template_mtime = os.stat(template_name).st_mtime
    mtime, plan = Plans_cache.get((starting_tables, template_name),
                                  (None, None))

# Path: pyke/knowledge_engine.py
#     class chain(object):
# class CanNotProve(StandardError):
# class engine(object):
#         def __new__(cls, *args):
#         def from_iterable(i):
#     def __init__(self, *search_paths, **kws):
#     def _create_target_pkg(self, path, target_pkgs):
#     def get_ask_module(self):
#     def reset(self):
#     def get_kb(self, kb_name, _new_class = None):
#     def get_rb(self, rb_name):
#     def get_create(self, rb_name, parent = None, exclude_list = ()):
#     def get_ke(self, kb_name, entity_name):
#     def add_universal_fact(self, kb_name, fact_name, args):
#     def add_case_specific_fact(self, kb_name, fact_name, args):
#     def assert_(self, kb_name, entity_name, args):
#     def activate(self, *rb_names):
#     def lookup(self, kb_name, entity_name, pat_context, patterns):
#     def prove_goal(self, goal_str, **args):
#     def prove_1_goal(self, goal_str, **args):
#     def prove(self, kb_name, entity_name, pat_context, patterns):
#     def prove_n(self, kb_name, entity_name, fixed_args = (), num_returns = 0):
#         def gen():
#     def prove_1(self, kb_name, entity_name, fixed_args = (), num_returns = 0):
#     def print_stats(self, f = sys.stdout):
#     def trace(self, rb_name, rule_name):
#     def untrace(self, rb_name, rule_name):
# def _get_target_pkg(target_name):
# def _pythonify_path(path):
# def _is_package_dir(path):
# def in_sys_path(path):
# 
# Path: pyke/krb_traceback.py
# def print_tb(traceback, limit=None, file=None):
# def print_exception(type, value, traceback, limit=None, file=None):
# def print_exc(limit=None, file=None):
# def format_exc(limit=None):
# def print_last(limit=None, file=None):
# def print_stack(f=None, limit=None, file=None):
# def extract_tb(tb, limit=None):
# def extract_stack(f=None, limit=None):
# def format_exception(type, value, traceback, limit=None):
# def format_tb(tb, limit=None):
# def format_stack(f=None, limit=None):
# def convert_lineno(module, lineno):
# def convert_tb(extracted_tb):


# Path: examples/web_framework/wsgi_app.py
import sys
import os, os.path
import sqlgen
from pyke import knowledge_engine, krb_traceback

    try:
        no_vars, plan = \
            Engine.prove_1_goal('web.process($starting_tables, $template_name)',
                                starting_tables=starting_tables,
                                template_name=template_name)
    except:
        traceback = krb_traceback.format_exc(100)
        return None, traceback
    return plan, None

Plans_cache = {}

def wsgi_app(environ, start_response):
    global Plans_cache

    # Parse the path:
    components = environ["PATH_INFO"].lstrip('/').split('/')
    template_name = os.path.join(Web_framework_dir, components[-1])
    starting_tables = []
    starting_keys = {}
    for i in range(0, len(components) - 1, 2):
        starting_tables.append(components[i])
        starting_keys[components[i]] = int(components[i + 1])
    # Convert to tuple so that it can be used as a dict key and sort so
    # different orders compare equal.
    starting_tables = tuple(sorted(starting_tables))

    template_mtime = os.stat(template_name).st_mtime
    mtime, plan = Plans_cache.get((starting_tables, template_name),
                                  (None, None))

    if mtime is None or mtime < template_mtime: