<commit_before>#
# This file is the power-advantage-tool recipe.
#

SUMMARY = "Power Advantage Tool"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

inherit jupyter-examples python3-dir

SRC_URI = "git://gitenterprise.xilinx.com/PowerAdvantageTool/jupyter-pat.git;protocol=https;nobranch=1"

PV = "2.2.0+git${SRCPV}"
SRCREV = "caec49c66e436ff0c47239c168054f02ac641790"


S = "${WORKDIR}/git"

COMPATIBLE_MACHINE = "^$"
COMPATIBLE_MACHINE_vck-sc-zynqmp = "vck-sc-zynqmp"

RDEPENDS_${PN} = "packagegroup-petalinux-jupyter \
                  python3-ipywidgets \
                  python3-pydot \
                  "
do_install() {
    install -d ${D}/${JUPYTER_DIR}/power-advantage-tool
    install -d ${D}/${JUPYTER_DIR}/power-advantage-tool/img
    install -d ${D}${PYTHON_SITEPACKAGES_DIR}/poweradvantage

    install -m 0755 ${S}/*.ipynb ${D}/${JUPYTER_DIR}/power-advantage-tool
    install -m 0755 ${S}/img/* ${D}/${JUPYTER_DIR}/power-advantage-tool/img
    install -m 0755 ${S}/poweradvantage/* ${D}${PYTHON_SITEPACKAGES_DIR}/poweradvantage
}

FILES_${PN} += "${PYTHON_SITEPACKAGES_DIR}/poweradvantage/* ${JUPYTER_DIR}/*"<commit_msg>power-advantage-tool: Customize .ipynb per board and SoC<commit_after>#
# This file is the power-advantage-tool recipe.
#

SUMMARY = "Power Advantage Tool"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

inherit jupyter-examples python3-dir

SRC_URI = "git://gitenterprise.xilinx.com/PowerAdvantageTool/jupyter-pat.git;protocol=https;nobranch=1"

PV = "2.2.0+git${SRCPV}"
SRCREV = "caec49c66e436ff0c47239c168054f02ac641790"


S = "${WORKDIR}/git"

COMPATIBLE_MACHINE = "^$"
COMPATIBLE_MACHINE_vck-sc-zynqmp = "vck-sc-zynqmp"

RDEPENDS_${PN} = "packagegroup-petalinux-jupyter \
                  python3-ipywidgets \
                  python3-pydot \
                  "
do_install() {
    install -d ${D}/${JUPYTER_DIR}/power-advantage-tool
    install -d ${D}/${JUPYTER_DIR}/power-advantage-tool/img
    install -d ${D}${PYTHON_SITEPACKAGES_DIR}/poweradvantage

    install -m 0755 ${S}/*.ipynb ${D}/${JUPYTER_DIR}/power-advantage-tool
    install -m 0755 ${S}/img/* ${D}/${JUPYTER_DIR}/power-advantage-tool/img
    install -m 0755 ${S}/poweradvantage/* ${D}${PYTHON_SITEPACKAGES_DIR}/poweradvantage
}

#
# The install_customize task 
# configures Power_Advantage_Tool.ipynb to the proper board and processor
# and copies the proper artwork to match the Jupyter Notebook background color
#
python do_install_customize () {
    import os
    import shutil
    token_old = "\\\"<KEY>\", \\\"SC\\\")\\n"
    path_source = d.getVar('S') + "/img_on_black"
    path_destination = d.getVar('D') + d.getVar('JUPYTER_DIR') + "/power-advantage-tool/img"
    path_ipynb = d.getVar('D') + d.getVar('JUPYTER_DIR') + "/power-advantage-tool/Power_Advantage_Tool.ipynb"
    if d.getVar('MACHINE') == 'vck-sc-zynqmp':
        token_new = "\\\"VCK190\\\", \\\"SC\\\")\\n"
    elif d.getVar('MACHINE') == 'vmk-sc-zynqmp':
        token_new = "\\\"VMK180\\\", \\\"SC\\\")\\n"
    elif d.getVar('MACHINE') == 'vpk-sc-zynqmp':
        token_new = "\\\"VPK120\\\", \\\"SC\\\")\\n"
    elif d.getVar('MACHINE') == 'vck190-versal':
        token_new = "\\\"VCK190\\\", \\\"\\\")\\n"
        shutil.rmtree(path_destination)
        shutil.copytree(path_source, path_destination)
    elif d.getVar('MACHINE') == 'vmk180-versal':
        token_new = "\\\"VMK180\\\", \\\"\\\")\\n"
        shutil.rmtree(path_destination)
        shutil.copytree(path_source, path_destination)
    elif d.getVar('MACHINE') == 'vpk120-versal':
        token_new = "\\\"VPK120\\\", \\\"\\\")\\n"
        shutil.rmtree(path_destination)
        shutil.copytree(path_source, path_destination)
    elif d.getVar('MACHINE') == 'vpk180-versal':
        token_new = "\\\"VPK180\\\", \\\"\\\")\\n"
        shutil.rmtree(path_destination)
        shutil.copytree(path_source, path_destination)
    file = open(path_ipynb, 'r')
    lines = file.readlines()
    file.close()
    file = open(path_ipynb, 'w')
    for line in lines:
        file.write(line.replace(token_old, token_new).replace("\n", "\r\n"))
    file.close()
}
addtask install_customize after do_install before do_build

FILES_${PN} += "${PYTHON_SITEPACKAGES_DIR}/poweradvantage/* ${JUPYTER_DIR}/*"
{'fraction_non_alphanumeric': 0.1778682959945689, 'fraction_numerical': 0.036886173342385156, 'mean_word_length': 3.402390438247012, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '4891789', 'n_tokens_mistral': 1882, 'n_tokens_neox': 1743, 'n_words': 251}