"""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 not MINDBENDER_FPS == "":
        cmds.currentUnit(time=(mayafpsconverter(MINDBENDER_FPS)))
    if not MINDBENDER_EDIT_IN == "":
        cmds.playbackOptions(animationStartTime=MINDBENDER_EDIT_IN)
    if not MINDBENDER_EDIT_OUT == "":
        cmds.playbackOptions(animationEndTime=MINDBENDER_EDIT_OUT)


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

@@ -1786,36 +1786,32 @@
 EIGHT%22)%0A%0A    if 
-not 
 MINDBENDER_FPS =
@@ -1809,17 +1809,17 @@
 DER_FPS 
-=
+!
 = %22%22:%0A  
@@ -1881,36 +1881,32 @@
 R_FPS)))%0A    if 
-not 
 MINDBENDER_EDIT_
@@ -1908,17 +1908,17 @@
 EDIT_IN 
-=
+!
 = %22%22:%0A  
@@ -1990,20 +1990,16 @@
 %0A    if 
-not 
 MINDBEND
@@ -2010,17 +2010,17 @@
 DIT_OUT 
-=
+!
 = %22%22:%0A  

update if statment