def obfuscate_global_import_methods(module, tokens, name_generator, table=None):
    """
    Replaces the used methods of globally-imported modules with obfuscated
    equivalents.  Updates *tokens* in-place.

    *module* must be the name of the module we're currently obfuscating

    If *table* is provided, replacements for import methods will be attempted
    to be looked up there before generating a new unique name.
    """
    global_imports = analyze.enumerate_global_imports(tokens)
    #print("global_imports: %s" % global_imports)
    local_imports = analyze.enumerate_local_modules(tokens, os.getcwd())
    #print("local_imports: %s" % local_imports)
    module_methods = analyze.enumerate_import_methods(tokens)
    #print("module_methods: %s" % module_methods)
    # Make a 1-to-1 mapping dict of module_method<->replacement:
    if table:
        replacement_dict = {}
        for module_method in module_methods:
            if module_method in table[0].keys():
                replacement_dict.update({module_method: table[0][module_method]})
            else:
                replacement_dict.update({module_method: next(name_generator)})
        # Update the global lookup table with the new entries:
        table[0].update(replacement_dict)
    else:
        method_map = [next(name_generator) for i in module_methods]
        replacement_dict = dict(zip(module_methods, method_map))
    import_line = False
    # Replace module methods with our obfuscated names in *tokens*
    for module_method in module_methods:
        for index, tok in enumerate(tokens):
            token_type = tok[0]
            token_string = tok[1]
            if token_type != tokenize.NAME:
                continue # Speedup
            tokens[index+1][1]
            if token_string == module_method.split('.')[0]:
                if tokens[index+1][1] == '.':
                    if tokens[index+2][1] == module_method.split('.')[1]:
                        if table: # Attempt to use an existing value
                            tokens[index][1] = table[0][module_method]
                            tokens[index+1][1] = ""
                            tokens[index+2][1] = ""
                        else:
                            tokens[index][1] = replacement_dict[module_method]
                            tokens[index+1][1] = ""
                            tokens[index+2][1] = ""
    # Insert our map of replacement=what after each respective module import
    for module_method, replacement in replacement_dict.items():
        indents = []
        index = 0
        for tok in tokens[:]:
            token_type = tok[0]
            token_string = tok[1]
            if token_type == tokenize.NEWLINE:
                import_line = False
            elif token_type == tokenize.INDENT:
                indents.append(tok)
            elif token_type == tokenize.DEDENT:
                indents.pop()
            elif token_string == "import":
                import_line = True
            elif import_line:
                if token_string == module_method.split('.')[0]:
                    # Insert the obfuscation assignment after the import
                    imported_module = ".".join(module_method.split('.')[:-1])
                    if table and imported_module in local_imports:
                        line = "%s=%s.%s\n" % ( # This ends up being 6 tokens
                            replacement_dict[module_method],
                            imported_module,
                            replacement_dict[module_method]
                        )
                    else:
                        line = "%s=%s\n" % ( # This ends up being 6 tokens
                            replacement_dict[module_method], module_method)
                    for indent in indents: # Fix indentation
                        line = "%s%s" % (indent[1], line)
                        index += 1
                    insert_in_next_line(tokens, index, line)
                    index += 6 # To make up for the six tokens we inserted
            index += 1
Replaces the used methods of globally-imported modules with obfuscated
    equivalents.  Updates *tokens* in-place.

    *module* must be the name of the module we're currently obfuscating

    If *table* is provided, replacements for import methods will be attempted
    to be looked up there before generating a new unique name.