Example #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()
Example #2
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()
Example #3
0
def write_doc_index(output_filename=None, db=None, help_command=None):
    if output_filename is None:
        output_filename = determine_doc_index_filename()
    user_provided_db = True
    if db is None:
        user_provided_db = False
        db = docs.load_doc_db(output_filename)
    if help_command is None:
        driver = awscli.clidriver.create_clidriver()
        help_command = driver.create_help_command()

    should_close = not user_provided_db
    do_write_doc_index(db, help_command, close_db_on_finish=should_close)
Example #4
0
def write_doc_index(output_filename=None, db=None, help_command=None):
    if output_filename is None:
        output_filename = determine_doc_index_filename()
    user_provided_db = True
    if db is None:
        user_provided_db = False
        db = docs.load_doc_db(output_filename)
    if help_command is None:
        driver = awscli.clidriver.create_clidriver()
        help_command = driver.create_help_command()

    should_close = not user_provided_db
    do_write_doc_index(db, help_command, close_db_on_finish=should_close)
Example #5
0
def test_load_doc_db(tmpdir):
    filename = tmpdir.join("foo.db").strpath
    d = docs.load_doc_db(filename)
    assert isinstance(d, db.ConcurrentDBM)