コード例 #1
0
ファイル: gear_renamer.py プロジェクト: jeanim/gear
def rename(PPG, name, i):

    if PPG.UseSearchReplace.Value:

        # Simple Mode ------------------------------------------------------
        if PPG.EditMode.Value == 0 and PPG.Search.Value != "":
            name = name.replace(PPG.Search.Value, PPG.Replace.Value)

        # Regular Expression ----------------------------------------------
        elif PPG.EditMode.Value == 1 and PPG.Search.Value != "":
            name = re.sub(PPG.Search.Value, PPG.Replace.Value, name)

        # Serialize --------------------------------------------------------
        elif PPG.EditMode.Value == 2:

            index = (i * PPG.step.Value) + PPG.start.Value

            # Use Letter
            if PPG.UseLetters.Value:

                if PPG.UpperCase.Value:
                    alphabet = UPPER_ALPHABET
                else:
                    alphabet = LOWER_ALPHABET

                if (index / 26) > 0:
                    letter = alphabet[index / 26] + alphabet[index % 26]
                else:
                    letter = alphabet[index % 26]

                while len(letter) < PPG.Replace.Value.count("#"):
                    letter = alphabet[0] + letter

                name = re.sub("#+", letter, PPG.Replace.Value)

            # Use Digit
            else:
                digit = str(index)
                while len(digit) < PPG.Replace.Value.count("#"):
                    digit = "0" + digit
                name = re.sub("#+", digit, PPG.Replace.Value)

    if PPG.AddPrefix.Value:
        name = PPG.Prefix.Value + name

    if PPG.AddSuffix.Value:
        name += PPG.Suffix.Value

    return string.normalize(name)
コード例 #2
0
ファイル: gear_renamer.py プロジェクト: EricTRocks/GEAR_mc
def rename(PPG, name, i):

    if PPG.UseSearchReplace.Value:

        # Simple Mode ------------------------------------------------------
        if PPG.EditMode.Value == 0 and PPG.Search.Value != "":
            name = name.replace(PPG.Search.Value, PPG.Replace.Value)

        # Regular Expression ----------------------------------------------
        elif PPG.EditMode.Value == 1 and PPG.Search.Value != "":
            name = re.sub(PPG.Search.Value, PPG.Replace.Value, name)

        # Serialize --------------------------------------------------------
        elif PPG.EditMode.Value == 2:

            index = (i * PPG.step.Value) + PPG.start.Value

            # Use Letter
            if PPG.UseLetters.Value:

                if PPG.UpperCase.Value:
                    alphabet = UPPER_ALPHABET
                else:
                    alphabet = LOWER_ALPHABET

                if (index/26) > 0:
                    letter = alphabet[index/26]+alphabet[index%26]
                else:
                    letter = alphabet[index%26]

                while len(letter) < PPG.Replace.Value.count("#"):
                    letter = alphabet[0]+letter

                name = re.sub("#+", letter, PPG.Replace.Value)

            # Use Digit
            else:
                digit = str(index)
                while len(digit) < PPG.Replace.Value.count("#"):
                    digit = "0"+digit
                name = re.sub("#+", digit, PPG.Replace.Value)

    if PPG.AddPrefix.Value:
        name = PPG.Prefix.Value + name

    if PPG.AddSuffix.Value:
        name += PPG.Suffix.Value

    return string.normalize(name)
コード例 #3
0
ファイル: gear_renamer.py プロジェクト: miquelcampos/GEAR_mc
def gear_Renamer_PreviewGrid_OnChanged():

    grid_data = PPG.PreviewGrid.Value
    for i in range(grid_data.RowCount):

        row_values = grid_data.GetRowValues(i)

        # Check if new entered name is not empty
        if row_values[2] == "":
            grid_data.SetRowValues(i, [row_values[0], row_values[1], row_values[1]])

        # Get a valid name
        row_values = grid_data.GetRowValues(i)
        grid_data.SetRowValues(i, [row_values[0], row_values[1], string.normalize(row_values[2])])

        setRowColor(grid_data, i)

    PPG.Refresh()
コード例 #4
0
ファイル: gear_renamer.py プロジェクト: jeanim/gear
def renameChain(PPG, obj):

    prop = PPG.Inspected(0)

    suffix = prop.Parameters(obj.Type + "Suffix").Value

    name = PPG.replace.Value + "_" + suffix

    if obj.Type == "bone":

        padding = len(str(obj.Root.Bones.Count - 1))

        for i, bone in enumerate(obj.Root.Bones):
            if bone.IsEqualTo(obj):
                index = i

        name = re.sub("#", "%0" + str(padding) + "i", name)
        name = name % index

    return string.normalize(name)
コード例 #5
0
ファイル: gear_renamer.py プロジェクト: EricTRocks/GEAR_mc
def renameChain(PPG, obj):

    prop = PPG.Inspected(0)

    suffix = prop.Parameters(obj.Type+"Suffix").Value

    name = PPG.replace.Value+"_"+suffix

    if obj.Type == "bone":

        padding = len(str(obj.Root.Bones.Count-1))

        for i, bone in enumerate(obj.Root.Bones):
            if bone.IsEqualTo(obj):
                index = i

        name = re.sub("#", "%0"+str(padding)+"i", name)
        name = name%index

    return string.normalize(name)