<commit_before>"""Maya initialisation for Mindbender pipeline"""

from maya import cmds

import os


def mayafpsconverter(fps):
    ERRORSTRING = "MINDBENDER_FPS variable has letters or bad value check the bat file"
    """This checks to see that the value in MINDBENDER_FPS.string
    doesn't conttain any letters
    exampel "12" is valid
    exampel "1a2" is invalid
    """
    if str(fps).isdigit() is False:
        cmds.confirmDialog(title="Enviroment variable error",
                           message=ERRORSTRING,
                           button="",
                           defaultButton="",
                           cancelButton="",
                           dismissString="")
        return ""
    return {
        "15": "game",
        "24": "film",
        "25": "pal",
        "30": "ntsc",
        "48": "show",
        "50": "palf",
        "60": "ntscf",
        None: "",
        "": "", }.get(fps, fps + "fps")


def setup():
    assert __import__("pyblish_maya").is_setup(), (
        "mindbender-core depends on pyblish_maya which has not "
        "yet been setup. Run pyblish_maya.setup()")

    from pyblish import api
    api.register_gui("pyblish_lite")

    from mindbender import api, maya
    api.install(maya)

    MINDBENDER_FPS = os.getenv("MINDBENDER_FPS")
    MINDBENDER_EDIT_IN = os.getenv("MINDBENDER_EDIT_IN")
    MINDBENDER_EDIT_OUT = os.getenv("MINDBENDER_EDIT_OUT")
    MINDBENDER_RESOLUTION_WIDTH = os.getenv("MINDBENDER_RESOLUTION_WIDTH")
    MINDBENDER_RESOLUTION_HEIGHT = os.getenv("MINDBENDER_RESOLUTION_HEIGHT")

    if MINDBENDER_FPS is not None:
        cmds.currentUnit(time=(mayafpsconverter(MINDBENDER_FPS)))
    if MINDBENDER_EDIT_IN is not None:
        cmds.playbackOptions(animationStartTime=MINDBENDER_EDIT_IN)
    if MINDBENDER_EDIT_OUT is not None:
        cmds.playbackOptions(animationEndTime=MINDBENDER_EDIT_OUT)
<commit_msg>Refactored userSetup.py The userSetup can never fail, especially not interactively; it handles initialisation and there is no telling what may go wrong if at any point in the module it stops running.<commit_after>"""Maya initialisation for Mindbender pipeline"""

from maya import cmds

import os


def setup():
    assert __import__("pyblish_maya").is_setup(), (
        "mindbender-core depends on pyblish_maya which has not "
        "yet been setup. Run pyblish_maya.setup()")

    from pyblish import api
    api.register_gui("pyblish_lite")

    from mindbender import api, maya
    api.install(maya)

    FPS = {
        "15": "game",
        "24": "film",
        "25": "pal",
        "30": "ntsc",
        "48": "show",
        "50": "palf",
        "60": "ntscf"
    }.get(os.getenv("MINDBENDER_FPS"), "pal")  # Default to "pal"

    EDIT_IN = os.getenv("MINDBENDER_EDIT_IN") or 1000
    EDIT_OUT = os.getenv("MINDBENDER_EDIT_OUT") or 1200
    RESOLUTION_WIDTH = os.getenv("MINDBENDER_RESOLUTION_WIDTH") or 1920
    RESOLUTION_HEIGHT = os.getenv("MINDBENDER_RESOLUTION_HEIGHT") or 1080

    cmds.setAttr("defaultResolution.width", RESOLUTION_WIDTH)
    cmds.setAttr("defaultResolution.height", RESOLUTION_HEIGHT)
    cmds.currentUnit(time=FPS)
    cmds.playbackOptions(animationStartTime=EDIT_IN)
    cmds.playbackOptions(animationEndTime=EDIT_OUT)

{'fraction_non_alphanumeric': 0.10817455439459127, 'fraction_numerical': 0.014751075599262446, 'mean_word_length': 3.0086206896551726, 'pattern_counts': {'":': 15, '<': 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': '2751442', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1086, 'n_words': 245}