# Path: scripts/dump_btree.py
# def main(argv=None):
# 
# Path: scripts/dump_types.py
# class TILEncoder(json.JSONEncoder):
#     def default(self, obj):
# def main(argv=None):
# 
# Path: scripts/dump_user.py
# def is_encrypted(buf):
# def decrypt(buf):
# def parse_user_data(buf):
# def get_userdata(netnode):
# def print_userdata(api, tag="$ original user"):
# def main(argv=None):
# HEXRAYS_PUBKEY = 0x93AF7A8E3A6EB93D1B4D1FB7EC29299D2BC8F3CE5F84BFE88E47DDBDD5550C3CE3D2B16A2E2FBD0FBD919E8038BB05752EC92DD1498CB283AA087A93184F1DD9DD5D5DF7857322DFCD70890F814B58448071BBABB0FC8A7868B62EB29CC2664C8FE61DFBC5DB0EE8BF6ECF0B65250514576C4384582211896E5478F95C42FDED
# 
# Path: scripts/dump_scripts.py
# def main(argv=None):
# 
# Path: scripts/extract_function_names.py
# def main(argv=None):
# 
# Path: scripts/extract_md5.py
# def main(argv=None):
# 
# Path: scripts/extract_version.py
# def main(argv=None):


from contextlib import contextmanager
from fixtures import DefaultKern32Specs, get_kern32_path
from scripts import (
    dump_btree,
    dump_types,
    dump_user,
    dump_scripts,
    extract_function_names,
    extract_md5,
    extract_version,
)
import pytest


@contextmanager
def not_raises(exception):
    try:
        yield
    except exception:
        raise pytest.fail("Unexpected raise {0}".format(exception))


def kern32_script_test(scripts, specs=None):
    if specs is None:
        specs = DefaultKern32Specs
    ids = []
    params = []
    for script in scripts:
        for spec in specs:
            version, bitness, expected = (
                spec
                if isinstance(spec[0], float) or isinstance(spec[0], int)
                else spec[1]
            )
            path, sversion, sbitness = get_kern32_path(version, bitness)
            params.append(pytest.param(path, version, bitness, expected, script))
            ids.append("/".join([sversion, sbitness, script.__name__]))
    return pytest.mark.parametrize(
        "kernel32_idb_path, version, bitness, expected, script", params, ids=ids
    )



# Path: scripts/dump_btree.py
# def main(argv=None):
# 
# Path: scripts/dump_types.py
# class TILEncoder(json.JSONEncoder):
#     def default(self, obj):
# def main(argv=None):
# 
# Path: scripts/dump_user.py
# def is_encrypted(buf):
# def decrypt(buf):
# def parse_user_data(buf):
# def get_userdata(netnode):
# def print_userdata(api, tag="$ original user"):
# def main(argv=None):
# HEXRAYS_PUBKEY = 0x93AF7A8E3A6EB93D1B4D1FB7EC29299D2BC8F3CE5F84BFE88E47DDBDD5550C3CE3D2B16A2E2FBD0FBD919E8038BB05752EC92DD1498CB283AA087A93184F1DD9DD5D5DF7857322DFCD70890F814B58448071BBABB0FC8A7868B62EB29CC2664C8FE61DFBC5DB0EE8BF6ECF0B65250514576C4384582211896E5478F95C42FDED
# 
# Path: scripts/dump_scripts.py
# def main(argv=None):
# 
# Path: scripts/extract_function_names.py
# def main(argv=None):
# 
# Path: scripts/extract_md5.py
# def main(argv=None):
# 
# Path: scripts/extract_version.py
# def main(argv=None):


# Path: tests/test_scripts.py
from contextlib import contextmanager
from fixtures import DefaultKern32Specs, get_kern32_path
from scripts import (
    dump_btree,
    dump_types,
    dump_user,
    dump_scripts,
    extract_function_names,
    extract_md5,
    extract_version,
)
import pytest



@contextmanager
def not_raises(exception):
    try:
        yield
    except exception:
        raise pytest.fail("Unexpected raise {0}".format(exception))


def kern32_script_test(scripts, specs=None):
    if specs is None:
        specs = DefaultKern32Specs
    ids = []
    params = []
    for script in scripts:
        for spec in specs:
            version, bitness, expected = (
                spec
                if isinstance(spec[0], float) or isinstance(spec[0], int)
                else spec[1]
            )
            path, sversion, sbitness = get_kern32_path(version, bitness)
            params.append(pytest.param(path, version, bitness, expected, script))
            ids.append("/".join([sversion, sbitness, script.__name__]))
    return pytest.mark.parametrize(
        "kernel32_idb_path, version, bitness, expected, script", params, ids=ids
    )



SlowScripts = [dump_btree, extract_function_names]