def obfuscate(module, tokens, options, name_generator=None, table=None):
<EOL>identifier_length = int(options.replacement_length)<EOL>ignore_length = False<EOL>if not name_generator:<EOL><INDENT>if options.use_nonlatin:<EOL><INDENT>ignore_length = True<EOL>if sys.version_info[<NUM_LIT:0>] == <NUM_LIT:3>:<EOL><INDENT>name_generator = obfuscation_machine(<EOL>use_unicode=True, identifier_length=identifier_length)<EOL><DEDENT>else:<EOL><INDENT>print(<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>name_generator = obfuscation_machine(<EOL>identifier_length=identifier_length)<EOL><DEDENT><DEDENT>if options.obfuscate:<EOL><INDENT>variables = find_obfuscatables(<EOL>tokens, obfuscatable_variable, ignore_length=ignore_length)<EOL>classes = find_obfuscatables(<EOL>tokens, obfuscatable_class)<EOL>functions = find_obfuscatables(<EOL>tokens, obfuscatable_function)<EOL>for variable in variables:<EOL><INDENT>replace_obfuscatables(<EOL>module,<EOL>tokens,<EOL>obfuscate_variable,<EOL>variable,<EOL>name_generator,<EOL>table<EOL>)<EOL><DEDENT>for function in functions:<EOL><INDENT>replace_obfuscatables(<EOL>module,<EOL>tokens,<EOL>obfuscate_function,<EOL>function,<EOL>name_generator,<EOL>table<EOL>)<EOL><DEDENT>for _class in classes:<EOL><INDENT>replace_obfuscatables(<EOL>module, tokens, obfuscate_class, _class, name_generator, table)<EOL><DEDENT>obfuscate_global_import_methods(module, tokens, name_generator, table)<EOL>obfuscate_builtins(module, tokens, name_generator, table)<EOL><DEDENT>else:<EOL><INDENT>if options.obf_classes:<EOL><INDENT>classes = find_obfuscatables(<EOL>tokens, obfuscatable_class)<EOL>for _class in classes:<EOL><INDENT>replace_obfuscatables(<EOL>module,<EOL>tokens,<EOL>obfuscate_class,<EOL>_class,<EOL>name_generator,<EOL>table<EOL>)<EOL><DEDENT><DEDENT>if options.obf_functions:<EOL><INDENT>functions = find_obfuscatables(<EOL>tokens, obfuscatable_function)<EOL>for function in functions:<EOL><INDENT>replace_obfuscatables(<EOL>module,<EOL>tokens,<EOL>obfuscate_function,<EOL>function,<EOL>name_generator,<EOL>table<EOL>)<EOL><DEDENT><DEDENT>if options.obf_variables:<EOL><INDENT>variables = find_obfuscatables(<EOL>tokens, obfuscatable_variable)<EOL>for variable in variables:<EOL><INDENT>replace_obfuscatables(<EOL>module,<EOL>tokens,<EOL>obfuscate_variable,<EOL>variable,<EOL>name_generator,<EOL>table<EOL>)<EOL><DEDENT><DEDENT>if options.obf_import_methods:<EOL><INDENT>obfuscate_global_import_methods(<EOL>module, tokens, name_generator, table)<EOL><DEDENT>if options.obf_builtins:<EOL><INDENT>obfuscate_builtins(module, tokens, name_generator, table)<EOL><DEDENT><DEDENT>
Obfuscates *tokens* in-place.  *options* is expected to be the options
variable passed through from pyminifier.py.

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

If *name_generator* is provided it will be used to obtain replacement values
for identifiers.  If not, a new instance of

If *table* is given (should be a list containing a single dictionary), it
will be used to perform lookups of replacements and any new replacements
will be added to it.