TEMPLATE_BASE64 and Fixes for STRUCTURE use#2846
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2846 +/- ##
==========================================
+ Coverage 78.66% 78.72% +0.06%
==========================================
Files 667 667
Lines 54452 54471 +19
Branches 731 731
==========================================
+ Hits 42834 42883 +49
+ Misses 11538 11508 -30
Partials 80 80
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| if data_type == "STRING": | ||
| return "" | ||
| else: | ||
| return bytearray(b'') |
There was a problem hiding this comment.
This is the fix for the ProtoAccessor with a blank TEMPLATE
| description: The template string which should be enclosed in quotes | ||
| values: "['\"].*['\"]" | ||
| since: 5.0.10 | ||
| TEMPLATE_BASE64: |
There was a problem hiding this comment.
Allows for binary templates in the text config file.
There was a problem hiding this comment.
Do we need this if we already have the TEMPLATE_FILE which can be binary?
| # Structure is used to write items with parent, not accessor | ||
| structure_buffer = read_item(item.parent_item, buffer) | ||
| structure = item.parent_item.structure | ||
| parent_item = @packet.get_item(item.parent_item) |
There was a problem hiding this comment.
Parent item changed from the actual item, to just the item name to lookup.
The new deep_copy in build_cmd() was copying the referenced item, and then not picking up bit_offset/bit_size dynamic changes.
|
| description: The template string which should be enclosed in quotes | ||
| values: "['\"].*['\"]" | ||
| since: 5.0.10 | ||
| TEMPLATE_BASE64: |
There was a problem hiding this comment.
Do we need this if we already have the TEMPLATE_FILE which can be binary?
| end | ||
| if self.parent_item | ||
| hash['parent_item'] = self.parent_item.as_json | ||
| hash['parent_item'] = self.parent_item |
There was a problem hiding this comment.
This will just be a string now right?
There was a problem hiding this comment.
Yes it is the parent item's name now, instead of a reference to the item itself.
| if data_type == "STRING": | ||
| return "" | ||
| else: | ||
| return bytearray(b"") |
There was a problem hiding this comment.
Python blocks are binary and therefore should always return a bytearray, not a string.
| if @validator | ||
| config << " VALIDATOR #{@validator.class} #{@validator.args.map { |a| a.to_s.quote_if_necessary }.join(" ")}\n" | ||
| end | ||
| # TODO: Add TEMPLATE_ENCODED so this can always be done inline regardless of content |
|
TEMPLATE_BASE64 is much more convenient than TEMPLATE_FILE as you can put the data in the same config file, rather than having to reference another file. File will still be useful for really big templates. |


No description provided.