예제 #1
0
def main():
    indexer = completion.CompletionIndex()
    try:
        index_str = indexer.load_index(utils.AWSCLI_VERSION)
        index_data = json.loads(index_str)
    except completion.IndexLoadError:
        print("First run, creating autocomplete index...")
        from awsshell.makeindex import write_index
        # TODO: Using internal method, but this will eventually
        # be moved into the CompletionIndex class anyways.
        index_file = indexer._filename_for_version(utils.AWSCLI_VERSION)
        write_index(index_file)
        index_str = indexer.load_index(utils.AWSCLI_VERSION)
        index_data = json.loads(index_str)
    doc_index_file = determine_doc_index_filename()
    from awsshell.makeindex import write_doc_index
    doc_data = docs.load_lazy_doc_index(doc_index_file)
    # There's room for improvement here.  If the docs didn't finish
    # generating, we regen the whole doc index.  Ideally we pick up
    # from where we left off.
    try:
        db = docs.load_doc_db(doc_index_file)
        db['__complete__']
    except KeyError:
        print("Creating doc index in the background. "
              "It will be a few minutes before all documentation is "
              "available.")
        t = threading.Thread(target=write_doc_index, args=(doc_index_file,))
        t.daemon = True
        t.start()
    model_completer = autocomplete.AWSCLIModelCompleter(index_data)
    completer = shellcomplete.AWSShellCompleter(model_completer)
    shell = app.create_aws_shell(completer, model_completer, doc_data)
    shell.run()
예제 #2
0
파일: __init__.py 프로젝트: zkan/aws-shell
def main():
    indexer = completion.CompletionIndex()
    try:
        index_str = indexer.load_index(utils.AWSCLI_VERSION)
        index_data = json.loads(index_str)
    except completion.IndexLoadError:
        print("First run, creating autocomplete index...")
        from awsshell.makeindex import write_index
        # TODO: Using internal method, but this will eventually
        # be moved into the CompletionIndex class anyways.
        index_file = indexer._filename_for_version(utils.AWSCLI_VERSION)
        write_index(index_file)
        index_str = indexer.load_index(utils.AWSCLI_VERSION)
        index_data = json.loads(index_str)
    doc_index_file = determine_doc_index_filename()
    from awsshell.makeindex import write_doc_index
    doc_data = docs.load_lazy_doc_index(doc_index_file)
    # There's room for improvement here.  If the docs didn't finish
    # generating, we regen the whole doc index.  Ideally we pick up
    # from where we left off.
    try:
        db = docs.load_doc_db(doc_index_file)
        db['__complete__']
    except KeyError:
        print("Creating doc index in the background. "
              "It will be a few minutes before all documentation is "
              "available.")
        t = threading.Thread(target=write_doc_index, args=(doc_index_file, ))
        t.daemon = True
        t.start()
    model_completer = autocomplete.AWSCLIModelCompleter(index_data)
    completer = shellcomplete.AWSShellCompleter(model_completer)
    shell = app.create_aws_shell(completer, model_completer, doc_data)
    shell.run()
예제 #3
0
def test_lazy_doc_factory(tmpdir):
    filename = tmpdir.join('foo.db').strpath
    doc_index = docs.load_lazy_doc_index(filename)
    assert isinstance(doc_index, docs.DocRetriever)