TagStudio
TagStudio copied to clipboard
[chore]Make get_field_attr safe and improve control flow in ts_core.py
Refactor get_field_attr in library.py and improve control flow in ts_core.py
Changes:
1. Refactor get_field_attr
in library.py
:
- Ensure safety using list slicing to avoid
IndexError
. - Use
any
to determine if there is a value before using it. - Use
.get()
for dictionary access to handle default cases and preventKeyError
.
2. Improve control flow in ts_core.py
:
- Remove nesting by exiting early in
match_conditions
. - Eliminate the need for try-catch blocks for better readability and control flow.
Additional Fix:
- Included fix for non-merged pull request #318.
Note:
- Kept
existing_fields
case unchanged due toadd_field_to_entry
's procedural nature.