"""Maya initialisation for Mindbender pipeline"""

from maya import cmds

import os


def mayafpsconverter(Sfps):
    condition = 0
    if Sfps is None:
        return ""
    if Sfps == "":
        condition = 1
        return Sfps
    if Sfps == "15":
        condition = 1
        return "game"
    if Sfps == "24":
        condition = 1
        return "film"
    if Sfps == "25":
        condition = 1
        return "pal"
    if Sfps == "30":
        condition = 1
        return "ntsc"
    if Sfps == "48":
        condition = 1
        return "show"
    if Sfps == "50":
        condition = 1
        return "palf"
    if Sfps == "60":
        condition = 1
        return "ntscf"
    ERRORSTRING = "MINDBENDER_FPS has bad value in the bat file"
    if str(Sfps).isdigit() is False:
        cmds.confirmDialog(title="Enviroment variable error",
                           message=ERRORSTRING,
                           button="",
                           defaultButton="",
                           cancelButton="",
                           dismissString="")
        return ""
    if condition == 0:
        Sfps = str(Sfps) + "fps"
        return Sfps


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)


# Allow time for dependencies (e.g. pyblish-maya)
# to be installed first.
cmds.evalDeferred(setup)

@@ -104,588 +104,14 @@
 ter(
-S
 fps):%0A
-    condition = 0%0A    if Sfps is None:%0A        return %22%22%0A    if Sfps == %22%22:%0A        condition = 1%0A        return Sfps%0A    if Sfps == %2215%22:%0A        condition = 1%0A        return %22game%22%0A    if Sfps == %2224%22:%0A        condition = 1%0A        return %22film%22%0A    if Sfps == %2225%22:%0A        condition = 1%0A        return %22pal%22%0A    if Sfps == %2230%22:%0A        condition = 1%0A        return %22ntsc%22%0A    if Sfps == %2248%22:%0A        condition = 1%0A        return %22show%22%0A    if Sfps == %2250%22:%0A        condition = 1%0A        return %22palf%22%0A    if Sfps == %2260%22:%0A        condition = 1%0A        return %22ntscf%22%0A
     
@@ -178,25 +178,24 @@
 %0A    if str(
-S
 fps).isdigit
@@ -515,79 +515,228 @@
     
-if condition == 0:%0A        Sfps = str(Sfps) + %22fps%22%0A        return S
+return %7B%0A        %2215%22: %22game%22,%0A        %2224%22: %22film%22,%0A        %2225%22: %22pal%22,%0A        %2230%22: %22ntsc%22,%0A        %2248%22: %22show%22,%0A        %2250%22: %22palf%22,%0A        %2260%22: %22ntscf%22,%0A        None: %22%22,%0A        %22%22: %22%22, %7D.get(fps, fps + %22
 fps
+%22)
 %0A%0A%0Ad

update much nice code from master that i stole it does the same thing.