Esempio n. 1
0
def fast_check_for_pia_skeleton(pia_filepath, skeleton):
    """Check for the skeleton record in PIA file without parsing the whole file.
    It takes filepath and skeleton name (string) and returns True if the skeleton
    record in the file is the same as skeleton name provided, otherwise False."""
    file = open(pia_filepath, 'r')
    while 1:
        data_type, line = _pix_parser.next_line(file)
        if data_type in ('EOF', 'ERR'):
            break
        # print('%s  ==> "%s"' % (data_type, line))
        if data_type == 'SE_S':
            section_type = re.split(r'[ ]+', line)[0]
            if section_type == "Global":
                # print('  %s' % section_type)
                data_type, line = _pix_parser.next_line(file)
                ske = re.split(r'"', line)[1]
                # print('  %r | %r' % (ske, skeleton))
                pia_skeleton = os.path.join(os.path.dirname(pia_filepath), ske)
                if os.path.isfile(pia_skeleton) and os.path.samefile(
                        pia_skeleton, skeleton):
                    file.close()
                    return True
                break
    file.close()
    return False
Esempio n. 2
0
def utter_check_for_pia_skeleton(pia_filepath, armature):
    """Skeleton analysis in PIA file with reasonably quick searching the whole file.
    It takes filepath and an Armature object and returns True if the skeleton in PIA file
    can be used for the skeleton in provided Armature object, otherwise it returns False."""
    file = open(pia_filepath, 'r')
    skeleton = None
    bone_matches = []
    while 1:
        data_type, line = _pix_parser.next_line(file)
        if data_type == 'EOF':
            if len(bone_matches) > 0:
                break
            else:
                file.close()
                return False, None
        if data_type == 'ERR':
            file.close()
            return False, None
        # print('%s  ==> "%s"' % (data_type, line))
        if data_type == 'SE_S':
            section_type = re.split(r'[ ]+', line)[0]
            if section_type == "Global":
                # print('  %s' % section_type)
                data_type, line = _pix_parser.next_line(file)
                line_split = re.split(r'"', line)
                # print('  %r | %r' % (line_split, skeleton))
                if line_split[0].strip() == "Skeleton:":
                    skeleton = line_split[1].strip()
            elif section_type == "BoneChannel":
                data_type, line = _pix_parser.next_line(file)
                # print('  %s - %s' % (data_type, line))
                prop_name = re.split(r'"', line)[1]
                # print('  %r' % prop_name)
                if prop_name in armature.data.bones:
                    bone_matches.append(prop_name)
                else:
                    file.close()
                    return False, None
    file.close()
    return True, skeleton
Esempio n. 3
0
def utter_check_for_pia_skeleton(pia_filepath, armature):
    """Skeleton analysis in PIA file with reasonably quick searching the whole file.
    It takes filepath and an Armature object and returns True if the skeleton in PIA file
    can be used for the skeleton in provided Armature object, otherwise it returns False."""
    file = open(pia_filepath, 'r')
    skeleton = None
    bone_matches = []
    while 1:
        data_type, line = _pix_parser.next_line(file)
        if data_type == 'EOF':
            if len(bone_matches) > 0:
                break
            else:
                file.close()
                return False, None
        if data_type == 'ERR':
            file.close()
            return False, None
        # print('%s  ==> "%s"' % (data_type, line))
        if data_type == 'SE_S':
            section_type = re.split(r'[ ]+', line)[0]
            if section_type == "Global":
                # print('  %s' % section_type)
                data_type, line = _pix_parser.next_line(file)
                line_split = re.split(r'"', line)
                # print('  %r | %r' % (line_split, skeleton))
                if line_split[0].strip() == "Skeleton:":
                    skeleton = line_split[1].strip()
            elif section_type == "BoneChannel":
                data_type, line = _pix_parser.next_line(file)
                # print('  %s - %s' % (data_type, line))
                prop_name = re.split(r'"', line)[1]
                # print('  %r' % prop_name)
                if prop_name in armature.data.bones:
                    bone_matches.append(prop_name)
                else:
                    file.close()
                    return False, None
    file.close()
    return True, skeleton
Esempio n. 4
0
def fast_check_for_pia_skeleton(pia_filepath, skeleton):
    """Check for the skeleton record in PIA file without parsing the whole file.
    It takes filepath and skeleton name (string) and returns True if the skeleton
    record in the file is the same as skeleton name provided, otherwise False."""
    file = open(pia_filepath, 'r')
    while 1:
        data_type, line = _pix_parser.next_line(file)
        if data_type in ('EOF', 'ERR'):
            break
        # print('%s  ==> "%s"' % (data_type, line))
        if data_type == 'SE_S':
            section_type = re.split(r'[ ]+', line)[0]
            if section_type == "Global":
                # print('  %s' % section_type)
                data_type, line = _pix_parser.next_line(file)
                ske = re.split(r'"', line)[1]
                # print('  %r | %r' % (ske, skeleton))
                pia_skeleton = os.path.join(os.path.dirname(pia_filepath), ske)
                if os.path.isfile(pia_skeleton) and os.path.samefile(pia_skeleton, skeleton):
                    file.close()
                    return True
                break
    file.close()
    return False