Exemplo n.º 1
0
def inner_loop(artifact_name):
    web_interface = WebDB()
    symbols = web_interface.get_artifact_symbols(artifact_name)
    all_symbol_tables = {}
    for top_level_name, keys in groupby(sorted(symbols),
                                        lambda x: x.partition(".")[0].lower()):
        print(top_level_name)
        # carve out for star imports which don't have dots
        if top_level_name == "*":
            continue
        # download the existing symbol table
        symbol_table_with_metadata = web_interface.get_symbol_table(
            top_level_name)
        symbol_table = symbol_table_with_metadata.get("symbol table", {})
        metadata = symbol_table_with_metadata.get("metadata", {})
        # update the symbol table
        for k in list(symbols):
            symbol_table.setdefault(k, []).append(artifact_name)
        # add artifacts to metadata
        metadata["version"] = version
        metadata.setdefault("indexed artifacts", []).append(artifact_name)
        # push back to server
        web_interface.push_symbol_table(top_level_name, {
            "symbol table": symbol_table,
            "metadata": metadata
        })
        all_symbol_tables[top_level_name] = symbol_table
    return all_symbol_tables
def inner_loop(artifact_name):
    web_interface = WebDB()
    symbols = web_interface.get_artifact_symbols(artifact_name)
    all_symbol_tables = {}
    for top_level_name, keys in groupby(sorted(symbols),
                                        lambda x: x.partition(".")[0].lower()):
        print(top_level_name)
        # carve out for star imports which don't have dots
        if top_level_name == "*":
            continue
        # download the existing symbol table metadata
        metadata = web_interface.get_symbol_table_metadata(
            top_level_name=top_level_name)
        if artifact_name in metadata.get("indexed artifacts", []):
            continue
        # download the existing symbol table
        symbol_table_with_metadata = web_interface.get_symbol_table(
            top_level_name)
        symbol_table = symbol_table_with_metadata.get("symbol table", {})
        # update the symbol table
        for k in list(keys):
            symbol_table_entry_value = {"artifact name": artifact_name}
            shadows = symbols[k].get("data", {}).get("shadows")
            if shadows:
                symbol_table_entry_value.update(shadows=shadows)
            symbol_table.setdefault(k, []).append(symbol_table_entry_value)
        # add artifacts to metadata
        metadata["version"] = version
        metadata.setdefault("indexed artifacts", []).append(artifact_name)
        # push back to server
        try:
            web_interface.push_symbol_table(top_level_name, {
                "symbol table": symbol_table,
                "metadata": metadata
            })
        except requests.RequestException as e:
            print(e)
        all_symbol_tables[top_level_name] = symbol_table
    return all_symbol_tables