def _add_single_stage(self, obj_filepath):
    import_stage_directory = os.path.dirname(obj_filepath)
    import_stage_base_name = str(os.path.basename(obj_filepath).split('.')[0])
    all_filenames = os.listdir(import_stage_directory)
    collected_filepaths = {}
    item_string = (import_stage_base_name + ' | has: [')
    for required_extension in self._required_extensions:
        for extension in required_extension:
            filename = ((import_stage_base_name + '.') + extension)
            if (filename in all_filenames):
                collected_filepaths[os.path.splitext(filename)[1][1:]] = os.path.join(import_stage_directory, filename)
                item_string += (extension + ', ')
                break
    item_string = (item_string[:(- 2)] + ']')
    all_textures_present = False
    if ('mtl' in collected_filepaths):
        with open(collected_filepaths['mtl'], 'r') as f:
            required_textures = []
            for line in f:
                split_line = line.strip().split()
                if (split_line and (split_line[0] == 'map_Kd')):
                    if os.path.isabs(split_line[1]):
                        required_textures.append(split_line[1])
                    else:
                        required_textures.append(os.path.join(import_stage_directory, split_line[1]))
        all_textures_present = all([os.path.exists(texture) for texture in required_textures])
    item_string += (' | textures: ' + ('yes' if all_textures_present else 'no'))
    with open(obj_filepath, 'r') as f:
        obj_lines = f.readlines()
    num_vertices = len([line for line in obj_lines if line.startswith('v ')])
    num_faces = len([line for line in obj_lines if line.startswith('f ')])
    item_string += (((' | v:' + str(num_vertices)) + ' f: ') + str(num_faces))
    all_inputs_met = ((len(collected_filepaths.keys()) == len(self._required_extensions)) and all_textures_present)
    item = QListWidgetItem()
    item.setData(self._input_filenames_key, collected_filepaths)
    item.setData(self._is_valid_input_key, all_inputs_met)
    item.setText(item_string)
    item.setIcon((QIcon('resources/green_checkmark.png') if all_inputs_met else QIcon('resources/red_xmark.png')))
    self._imported_stages_list.addItem(item)
    return Status.OK
def _add_single_stage(self, obj_filepath):
    import_stage_directory = os.path.dirname(obj_filepath)
    import_stage_base_name = str(os.path.basename(obj_filepath).split('.')[0])
    all_filenames = os.listdir(import_stage_directory)
    collected_filepaths = {}
    item_string = (import_stage_base_name + ' | has: [')
    for required_extension in self._required_extensions:
        for extension in required_extension:
            filename = ((import_stage_base_name + '.') + extension)
            if (filename in all_filenames):
                collected_filepaths[os.path.splitext(filename)[1][1:]] = os.path.join(import_stage_directory, filename)
                item_string += (extension + ', ')
                break
    item_string = (item_string[:(- 2)] + ']')
    all_textures_present = False
    if ('mtl' in collected_filepaths):
        with open(collected_filepaths['mtl'], 'r') as f:
            required_textures = []
            for line in f:
                split_line = line.strip().split()
                if (split_line and (split_line[0] == 'map_Kd')):
                    if os.path.isabs(split_line[1]):
                        required_textures.append(split_line[1])
                    else:
                        required_textures.append(os.path.join(import_stage_directory, split_line[1]))
        all_textures_present = all([os.path.exists(texture) for texture in required_textures])
    item_string += (' | textures: ' + ('yes' if all_textures_present else 'no'))
    with open(obj_filepath, 'r') as f:
        obj_lines = f.readlines()
    num_vertices = len([line for line in obj_lines if line.startswith('v ')])
    num_faces = len([line for line in obj_lines if line.startswith('f ')])
    item_string += (((' | v:' + str(num_vertices)) + ' f: ') + str(num_faces))
    all_inputs_met = ((len(collected_filepaths.keys()) == len(self._required_extensions)) and all_textures_present)
    item = QListWidgetItem()
    item.setData(self._input_filenames_key, collected_filepaths)
    item.setData(self._is_valid_input_key, all_inputs_met)
    item.setText(item_string)
    item.setIcon((QIcon('resources/green_checkmark.png') if all_inputs_met else QIcon('resources/red_xmark.png')))
    self._imported_stages_list.addItem(item)
    return Status.OK