[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
anyto 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_fieldscase unchanged due toadd_field_to_entry's procedural nature.
FYI, in the future you don't need to close and open a new PR when you want to add new commits. You can just (sometimes, force) push to the same remote branch
@seakrueger I know, but I didn't know if id find what was the introduced issue on time, so to prevent people wasting time taking a look I closed it and created a new one when ready. cheers
I'm afraid this PR is now obsolete when #332 has been merged. If you disagree, feel free to reopen it.