A bug in afcommon.py

Post Reply
Mikas
Posts: 19
Joined: Thu Oct 10, 2019 8:52 am

A bug in afcommon.py

Post by Mikas » Sat Apr 25, 2020 12:20 pm

Hi, I found and fixed a bug in afcommon.py
There was a problem with separate mantra node rendering with custom command more than 100 frames. Basically if first frame began with the same digit as the beginning of the last - it added a number to the ifd sequence thus failing mantra render.
example:
first frame: name_1.ifd
last frame: name_100.ifd
output: name_1.@#@.ifd
expected output: name_.@#@.ifd

Here is a fix (commented the fixed part)

Code: Select all

def splitPathsDifference(path_a, path_b):
    """Split paths searching for difference, return equal part before
    difference, difference length, part after difference

    :param str path_a:
    :param str path_b:
    """
    part_1 = path_a
    part_2 = ''
    diflength = 0

    len_a = len(path_a)
    len_b = len(path_b)
    len_min = len_a
    if len_min > len_b:
        len_min = len_b

    if len_min < 1:
        return part_1, diflength, part_2

# This part did not check if last equal symbol is not a digit
    len_begin = -1
    for c in range(len_min):
        if path_a[c] == path_b[c]:
            continue
        if str(c) not in Digits: # I added that check
            len_begin = c
        else:
            len_begin = c-1 # If digit - last equal symbol should be the one before
        break

    if len_begin < 1:
        return part_1, diflength, part_2

    len_end = -1
    for c in range(len_min):
        if path_a[len_a - c - 1] == path_b[len_b - c - 1]:
            continue
        len_end = c
        break

    if len_end < 1:
        return part_1, diflength, part_2

    for c in range(len_begin):
        if path_a[len_begin - c] in Digits:
            continue
        len_begin = len_begin - c + 1
        break

    for c in range(len_end):
        if path_a[len_a - len_end + c] in Digits:
            continue
        len_end -= c
        break

    diflength = 1
    if len_a == len_b:
        diflength = len_a - len_begin - len_end

    part_1 = path_a[0:len_begin]
    part_2 = path_a[len_a - len_end:len_a]

    return part_1, diflength, part_2
Mikas
Renderfarm - Ubuntu 18.04 LTS
Clients - mixed Windows and Linux

User avatar
timurhai
Site Admin
Posts: 580
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: A bug in afcommon.py

Post by timurhai » Sun Apr 26, 2020 12:35 pm

Hi!
Can you create a pull request here?
https://github.com/CGRU/cgru
This is the best way for a collaborate work.

(if not, i will apply changes manually, by hands)
Timur Hairulin
CGRU 2.4.0, Ubuntu 18.04 LTS, MS Windows 10 (clients only).

Mikas
Posts: 19
Joined: Thu Oct 10, 2019 8:52 am

Re: A bug in afcommon.py

Post by Mikas » Sun Apr 26, 2020 12:39 pm

I can try to do that a bit later at the beginning of the next week. Pretty busy finishing current project at the moment.
Mikas
Renderfarm - Ubuntu 18.04 LTS
Clients - mixed Windows and Linux

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests