<commit_before># Copyright (c) 1999 <NAME>
# Copyright (c) 2000-2002 by <NAME> <<EMAIL>>
# Copyright (c) 2005 by <NAME> <<EMAIL>>
# Copyright (c) 2015 by <NAME>

"""
CPython magic- and version- independent disassembly routines

There are two reasons we can't use Python's built-in routines
from dis. First, the bytecode we are extracting may be from a different
version of Python (different magic number) than the version of Python
that is doing the extraction.

Second, we need structured instruction information for the
(de)-parsing step. Python 3.4 and up provides this, but we still do
want to run on Python 2.7.
"""

from __future__ import print_function

import inspect, os, py_compile, sys, tempfile

import uncompyle6
from uncompyle6 import PYTHON3
from uncompyle6.scanner import get_scanner

def check_object_path(path):
    if path.endswith(".py"):
        try:
            import importlib
            return importlib.util.cache_from_source(path,
                                                    optimization='')
        except:
            try:
                import imp
                imp.cache_from_source(path, debug_override=False)
            except:
                pass
            pass
        basename = os.path.basename(path)[0:-3]
        spath = path if PYTHON3 else path.decode('utf-8')
        path = tempfile.mkstemp(prefix=basename + '-',
                                suffix='.pyc', text=False)[1]
        py_compile.compile(spath, cfile=path)

    if not path.endswith(".pyc") and not path.endswith(".pyo"):
        raise ValueError("path %s must point to a .py or .pyc file" %
                         path)
    return path

def disco(version, co, out=None):
    """
    diassembles and deparses a given code block 'co'
    """

    assert inspect.iscode(co)

    # store final output stream for case of error
    real_out = out or sys.stdout
    print('# Python %s' % version, file=real_out)
    if co.co_filename:
        print('# Embedded file name: %s' % co.co_filename,
              file=real_out)

    scanner = get_scanner(version)
    tokens, customize = scanner.disassemble(co)

    print(file=out)


def disassemble_file(filename, outstream=None):
    """
    disassemble Python byte-code file (.pyc)

    If given a Python source file (".py") file, we'll
    try to find the corresponding compiled object.
    """
    filename = check_object_path(filename)
    version, magic_int, co = uncompyle6.load_module(filename)
    if type(co) == list:
        for con in co:<commit_msg>dissasemble_file output is needed for pytest<commit_after># Copyright (c) 1999 <NAME>
# Copyright (c) 2000-2002 by <NAME> <<EMAIL>>
# Copyright (c) 2005 by <NAME> <<EMAIL>>
# Copyright (c) 2015 by <NAME>

"""
CPython magic- and version- independent disassembly routines

There are two reasons we can't use Python's built-in routines
from dis. First, the bytecode we are extracting may be from a different
version of Python (different magic number) than the version of Python
that is doing the extraction.

Second, we need structured instruction information for the
(de)-parsing step. Python 3.4 and up provides this, but we still do
want to run on Python 2.7.
"""

from __future__ import print_function

import inspect, os, py_compile, sys, tempfile

import uncompyle6
from uncompyle6 import PYTHON3
from uncompyle6.scanner import get_scanner

def check_object_path(path):
    if path.endswith(".py"):
        try:
            import importlib
            return importlib.util.cache_from_source(path,
                                                    optimization='')
        except:
            try:
                import imp
                imp.cache_from_source(path, debug_override=False)
            except:
                pass
            pass
        basename = os.path.basename(path)[0:-3]
        spath = path if PYTHON3 else path.decode('utf-8')
        path = tempfile.mkstemp(prefix=basename + '-',
                                suffix='.pyc', text=False)[1]
        py_compile.compile(spath, cfile=path)

    if not path.endswith(".pyc") and not path.endswith(".pyo"):
        raise ValueError("path %s must point to a .py or .pyc file" %
                         path)
    return path

def disco(version, co, out=None):
    """
    diassembles and deparses a given code block 'co'
    """

    assert inspect.iscode(co)

    # store final output stream for case of error
    real_out = out or sys.stdout
    print('# Python %s' % version, file=real_out)
    if co.co_filename:
        print('# Embedded file name: %s' % co.co_filename,
              file=real_out)

    scanner = get_scanner(version)
    tokens, customize = scanner.disassemble(co)

    for t in tokens:
        print(t, file=real_out)
    print(file=out)


def disassemble_file(filename, outstream=None):
    """
    disassemble Python byte-code file (.pyc)

    If given a Python source file (".py") file, we'll
    try to find the corresponding compiled object.
    """
    filename = check_object_path(filename)
    version, magic_int, co = uncompyle6.load_module(filename)
    if type(co) == list:
        for con in co:
{'fraction_non_alphanumeric': 0.09432127576818358, 'fraction_numerical': 0.013224426293271101, 'mean_word_length': 2.5034059945504086, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7419575', 'n_tokens_mistral': 1582, 'n_tokens_neox': 1487, 'n_words': 510}