mirror of
https://github.com/DarklightGames/io_scene_psk_psa.git
synced 2025-02-25 21:18:01 +01:00
Fixing PEP warnings
This commit is contained in:
parent
6b8088225a
commit
c65fdaa6a4
@ -14,7 +14,7 @@ class PsaConfig:
|
|||||||
|
|
||||||
|
|
||||||
def _load_config_file(file_path: str) -> ConfigParser:
|
def _load_config_file(file_path: str) -> ConfigParser:
|
||||||
'''
|
"""
|
||||||
UEViewer exports a dialect of INI files that is not compatible with Python's ConfigParser.
|
UEViewer exports a dialect of INI files that is not compatible with Python's ConfigParser.
|
||||||
Specifically, it allows values in this format:
|
Specifically, it allows values in this format:
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ def _load_config_file(file_path: str) -> ConfigParser:
|
|||||||
|
|
||||||
This is not allowed in Python's ConfigParser, which requires a '=' character after each key name.
|
This is not allowed in Python's ConfigParser, which requires a '=' character after each key name.
|
||||||
To work around this, we'll modify the file to add the '=' character after each key name if it is missing.
|
To work around this, we'll modify the file to add the '=' character after each key name if it is missing.
|
||||||
'''
|
"""
|
||||||
with open(file_path, 'r') as f:
|
with open(file_path, 'r') as f:
|
||||||
lines = f.read().split('\n')
|
lines = f.read().split('\n')
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ def _load_config_file(file_path: str) -> ConfigParser:
|
|||||||
def _get_bone_flags_from_value(value: str) -> int:
|
def _get_bone_flags_from_value(value: str) -> int:
|
||||||
match value:
|
match value:
|
||||||
case 'all':
|
case 'all':
|
||||||
return (REMOVE_TRACK_LOCATION | REMOVE_TRACK_ROTATION)
|
return REMOVE_TRACK_LOCATION | REMOVE_TRACK_ROTATION
|
||||||
case 'trans':
|
case 'trans':
|
||||||
return REMOVE_TRACK_LOCATION
|
return REMOVE_TRACK_LOCATION
|
||||||
case 'rot':
|
case 'rot':
|
||||||
|
@ -32,7 +32,6 @@ class PSA_UL_export_sequences(UIList):
|
|||||||
subrow = row.row(align=True)
|
subrow = row.row(align=True)
|
||||||
subrow.prop(pg, 'sequence_filter_name', text='')
|
subrow.prop(pg, 'sequence_filter_name', text='')
|
||||||
subrow.prop(pg, 'sequence_use_filter_invert', text='', icon='ARROW_LEFTRIGHT')
|
subrow.prop(pg, 'sequence_use_filter_invert', text='', icon='ARROW_LEFTRIGHT')
|
||||||
# subrow.prop(pg, 'sequence_use_filter_sort_reverse', text='', icon='SORT_ASC')
|
|
||||||
|
|
||||||
if pg.sequence_source == 'ACTIONS':
|
if pg.sequence_source == 'ACTIONS':
|
||||||
subrow = row.row(align=True)
|
subrow = row.row(align=True)
|
||||||
@ -44,7 +43,6 @@ class PSA_UL_export_sequences(UIList):
|
|||||||
pg = getattr(context.scene, 'psa_export')
|
pg = getattr(context.scene, 'psa_export')
|
||||||
actions = getattr(data, prop)
|
actions = getattr(data, prop)
|
||||||
flt_flags = filter_sequences(pg, actions)
|
flt_flags = filter_sequences(pg, actions)
|
||||||
# flt_neworder = bpy.types.UI_UL_list.sort_items_by_name(actions, 'name')
|
|
||||||
flt_neworder = list(range(len(actions)))
|
flt_neworder = list(range(len(actions)))
|
||||||
return flt_flags, flt_neworder
|
return flt_flags, flt_neworder
|
||||||
|
|
||||||
|
@ -64,12 +64,12 @@ class PsaImportResult:
|
|||||||
|
|
||||||
|
|
||||||
def _get_armature_bone_index_for_psa_bone(psa_bone_name: str, armature_bone_names: List[str], bone_mapping_mode: str = 'EXACT') -> Optional[int]:
|
def _get_armature_bone_index_for_psa_bone(psa_bone_name: str, armature_bone_names: List[str], bone_mapping_mode: str = 'EXACT') -> Optional[int]:
|
||||||
'''
|
"""
|
||||||
@param psa_bone_name: The name of the PSA bone.
|
@param psa_bone_name: The name of the PSA bone.
|
||||||
@param armature_bone_names: The names of the bones in the armature.
|
@param armature_bone_names: The names of the bones in the armature.
|
||||||
@param bone_mapping_mode: One of 'EXACT' or 'CASE_INSENSITIVE'.
|
@param bone_mapping_mode: One of 'EXACT' or 'CASE_INSENSITIVE'.
|
||||||
@return: The index of the armature bone that corresponds to the given PSA bone, or None if no such bone exists.
|
@return: The index of the armature bone that corresponds to the given PSA bone, or None if no such bone exists.
|
||||||
'''
|
"""
|
||||||
for armature_bone_index, armature_bone_name in enumerate(armature_bone_names):
|
for armature_bone_index, armature_bone_name in enumerate(armature_bone_names):
|
||||||
if bone_mapping_mode == 'CASE_INSENSITIVE':
|
if bone_mapping_mode == 'CASE_INSENSITIVE':
|
||||||
if armature_bone_name.lower() == psa_bone_name.lower():
|
if armature_bone_name.lower() == psa_bone_name.lower():
|
||||||
|
@ -23,11 +23,11 @@ def _try_fix_cue4parse_issue_103(sequences) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
class PsaReader(object):
|
class PsaReader(object):
|
||||||
'''
|
"""
|
||||||
This class reads the sequences and bone information immediately upon instantiation and holds onto a file handle.
|
This class reads the sequences and bone information immediately upon instantiation and holds onto a file handle.
|
||||||
The keyframe data is not read into memory upon instantiation due to its potentially very large size.
|
The keyframe data is not read into memory upon instantiation due to its potentially very large size.
|
||||||
To read the key data for a particular sequence, call :read_sequence_keys.
|
To read the key data for a particular sequence, call :read_sequence_keys.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.keys_data_offset: int = 0
|
self.keys_data_offset: int = 0
|
||||||
@ -43,11 +43,11 @@ class PsaReader(object):
|
|||||||
return self.psa.sequences
|
return self.psa.sequences
|
||||||
|
|
||||||
def read_sequence_data_matrix(self, sequence_name: str) -> np.ndarray:
|
def read_sequence_data_matrix(self, sequence_name: str) -> np.ndarray:
|
||||||
'''
|
"""
|
||||||
Reads and returns the data matrix for the given sequence.
|
Reads and returns the data matrix for the given sequence.
|
||||||
@param sequence_name: The name of the sequence.
|
@param sequence_name: The name of the sequence.
|
||||||
@return: An FxBx7 matrix where F is the number of frames, B is the number of bones.
|
@return: An FxBx7 matrix where F is the number of frames, B is the number of bones.
|
||||||
'''
|
"""
|
||||||
sequence = self.psa.sequences[sequence_name]
|
sequence = self.psa.sequences[sequence_name]
|
||||||
keys = self.read_sequence_keys(sequence_name)
|
keys = self.read_sequence_keys(sequence_name)
|
||||||
bone_count = len(self.bones)
|
bone_count = len(self.bones)
|
||||||
@ -60,12 +60,12 @@ class PsaReader(object):
|
|||||||
return matrix
|
return matrix
|
||||||
|
|
||||||
def read_sequence_keys(self, sequence_name: str) -> List[Psa.Key]:
|
def read_sequence_keys(self, sequence_name: str) -> List[Psa.Key]:
|
||||||
'''
|
"""
|
||||||
Reads and returns the key data for a sequence.
|
Reads and returns the key data for a sequence.
|
||||||
|
|
||||||
@param sequence_name: The name of the sequence.
|
@param sequence_name: The name of the sequence.
|
||||||
@return: A list of Psa.Keys.
|
@return: A list of Psa.Keys.
|
||||||
'''
|
"""
|
||||||
# Set the file reader to the beginning of the keys data
|
# Set the file reader to the beginning of the keys data
|
||||||
sequence = self.psa.sequences[sequence_name]
|
sequence = self.psa.sequences[sequence_name]
|
||||||
data_size = sizeof(Psa.Key)
|
data_size = sizeof(Psa.Key)
|
||||||
|
@ -3,6 +3,7 @@ from bpy.types import PropertyGroup, Material
|
|||||||
|
|
||||||
from ...types import PSX_PG_bone_collection_list_item
|
from ...types import PSX_PG_bone_collection_list_item
|
||||||
|
|
||||||
|
empty_set = set()
|
||||||
|
|
||||||
class PSK_PG_material_list_item(PropertyGroup):
|
class PSK_PG_material_list_item(PropertyGroup):
|
||||||
material: PointerProperty(type=Material)
|
material: PointerProperty(type=Material)
|
||||||
@ -12,7 +13,7 @@ class PSK_PG_material_list_item(PropertyGroup):
|
|||||||
class PSK_PG_export(PropertyGroup):
|
class PSK_PG_export(PropertyGroup):
|
||||||
bone_filter_mode: EnumProperty(
|
bone_filter_mode: EnumProperty(
|
||||||
name='Bone Filter',
|
name='Bone Filter',
|
||||||
options=set(),
|
options=empty_set,
|
||||||
description='',
|
description='',
|
||||||
items=(
|
items=(
|
||||||
('ALL', 'All', 'All bones will be exported'),
|
('ALL', 'All', 'All bones will be exported'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user