<commit_before>from __future__ import print_function
import datetime, os, sys

from uncompyle6 import verify, PYTHON_VERSION, IS_PYPY
from xdis.code import iscode
from uncompyle6.disas import check_object_path
from uncompyle6.semantics import pysource
from uncompyle6.parser import ParserError

from xdis.load import load_module

def uncompyle(
        version, co, out=None, showasm=False, showast=False,
        timestamp=None, showgrammar=False, code_objects={},
        is_pypy=False, magic_int=None):
    """
    ingests and deparses a given code block 'co'
    """
    assert iscode(co)

    # store final output stream for case of error
    real_out = out or sys.stdout
    co_pypy_str = 'PyPy ' if is_pypy else ''
    run_pypy_str = 'PyPy ' if IS_PYPY else ''
    print('# %sPython bytecode %s%s disassembled from %sPython %s' %
          (co_pypy_str, version,
           " (%d)" % magic_int if magic_int else "",
           run_pypy_str, PYTHON_VERSION),
          file=real_out)
    if co.co_filename:
        print('# Embedded file name: %s' % co.co_filename,
              file=real_out)
    if timestamp:
        print('# Compiled at: %s' % datetime.datetime.fromtimestamp(timestamp),
              file=real_out)

    try:
        pysource.deparse_code(version, co, out, showasm, showast, showgrammar,
                              code_objects=code_objects, is_pypy=is_pypy)
    except pysource.SourceWalkerError as e:
        # deparsing failed
        print("\n")
        print(co.co_filename)
        if real_out != out:
            print("\n", file=real_out)
            print(e, file=real_out)



def uncompyle_file(filename, outstream=None, showasm=False, showast=False,
                   showgrammar=False):
    """
    decompile Python byte-code file (.pyc)
    """

    filename = check_object_path(filename)
    code_objects = {}
    (version, timestamp, magic_int, co, is_pypy,
     source_size) = load_module(filename, code_objects)


    if type(co) == list:
        for con in co:
            uncompyle(version, con, outstream, showasm, showast,
                      timestamp, showgrammar, code_objects=code_objects,
                      is_pypy=is_pypy, magic_int=magic_int)
    else:
        uncompyle(version, co, outstream, showasm, showast,
                  timestamp, showgrammar, code_objects=code_objects,
                  is_pypy=is_pypy, magic_int=magic_int)
    co = None

# FIXME: combine into an options parameter
def main(in_base, out_base, files, codes, outfile=None,
         showasm=False, showast=False, do_verify=False,
         showgrammar=False, raise_on_error=False):
    """
    in_base	base directory for input files
    out_base	base directory for output files (ignored when
    files	list of filenames to be uncompyled (relative to src_base)
    outfile	write output to this filename (overwrites out_base)<commit_msg>Change meta data info in uncompyle6:<commit_after>from __future__ import print_function
import datetime, os, sys

from uncompyle6 import verify, IS_PYPY
from xdis.code import iscode
from uncompyle6.disas import check_object_path
from uncompyle6.semantics import pysource
from uncompyle6.parser import ParserError
from uncompyle6.version import VERSION

from xdis.load import load_module

def uncompyle(
        bytecode_version, co, out=None, showasm=False, showast=False,
        timestamp=None, showgrammar=False, code_objects={},
        source_size=None, is_pypy=False, magic_int=None):
    """
    ingests and deparses a given code block 'co'
    """
    assert iscode(co)

    # store final output stream for case of error
    real_out = out or sys.stdout
    co_pypy_str = 'PyPy ' if is_pypy else ''
    run_pypy_str = 'PyPy ' if IS_PYPY else ''
    print('# uncompyle6 version %s\n'
          '# %sPython bytecode %s%s\n# Disassembled from: %sPython %s' %
          (VERSION, co_pypy_str, bytecode_version,
           " (%d)" % magic_int if magic_int else "",
           run_pypy_str, '\n# '.join(sys.version.split('\n'))),
           file=real_out)
    if co.co_filename:
        print('# Embedded file name: %s' % co.co_filename,
              file=real_out)
    if timestamp:
        print('# Compiled at: %s' % datetime.datetime.fromtimestamp(timestamp),
              file=real_out)
    if source_size:
        print('# Size of source mod 2**32: %d bytes' % source_size,
               file=real_out)

    try:
        pysource.deparse_code(bytecode_version, co, out, showasm, showast,
                              showgrammar, code_objects=code_objects,
                              is_pypy=is_pypy)
    except pysource.SourceWalkerError as e:
        # deparsing failed
        print("\n")
        print(co.co_filename)
        if real_out != out:
            print("\n", file=real_out)
            print(e, file=real_out)



def uncompyle_file(filename, outstream=None, showasm=False, showast=False,
                   showgrammar=False):
    """
    decompile Python byte-code file (.pyc)
    """

    filename = check_object_path(filename)
    code_objects = {}
    (version, timestamp, magic_int, co, is_pypy,
     source_size) = load_module(filename, code_objects)


    if type(co) == list:
        for con in co:
            uncompyle(version, con, outstream, showasm, showast,
                      timestamp, showgrammar, code_objects=code_objects,
                      is_pypy=is_pypy, magic_int=magic_int)
    else:
        uncompyle(version, co, outstream, showasm, showast,
                  timestamp, showgrammar,
                  code_objects=code_objects, source_size=source_size,
                  is_pypy=is_pypy, magic_int=magic_int)
    co = None

# FIXME: combine into an options parameter
def main(in_base, out_base, files, codes, outfile=None,
         showasm=False, showast=False, do_verify=False,
         showgrammar=False, raise_on_error=False):
    """
    in_base	base directory for input files
    out_base	base directory for output files (ignored when
    files	list of filenames to be uncompyled (relative to src_base)
    outfile	write output to this filename (overwrites out_base)
{'fraction_non_alphanumeric': 0.08913967942427216, 'fraction_numerical': 0.002289826627412496, 'mean_word_length': 2.7377750611246943, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1503974', 'n_tokens_mistral': 1970, 'n_tokens_neox': 1917, 'n_words': 502}