-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python API and docs #51
Comments
For pretty-print see #10. |
Well, there actually is an API, if one compiles the spec in You can easily see how this API looks like e.g. by dropping this KSY meta:
id: debug_test
ks-debug: true
seq:
- id: a
size: 4
- id: b
type: u1 in the devel Web IDE and compiling it for Python. The def _read(self):
self._debug['a']['start'] = self._io.pos()
self.a = self._io.read_bytes(4)
self._debug['a']['end'] = self._io.pos()
self._debug['b']['start'] = self._io.pos()
self.b = self._io.read_u1()
self._debug['b']['end'] = self._io.pos() which is pretty much self-explanatory. One can get the size of the attribute |
Yeah, this mode was meant under
the mode storing offsets
AFAIK it is not called `debug` anymore.
|
I thought that https://github.com/kaitai-io/kaitai_struct_visualizer sums up and shows total size as As for #10 I would prefer the API to be cross-language with a method name like |
|
s>I would prefer the API to be cross-language with a method name like .dump() If you named the method So the method of computing of the repr is language-specific - we don't want to store redundant information. Also languages usually have well-known conventions for such stuff, and other people code expects everyone to follow them in order to operate as intended, IMHO we should follow them. |
Then all Python API should be standalone functions exported from runtime? |
python api functions in |
kaitai-io/kaitai_struct#299 discusses supporting each language's native "to string" feature in KS-generated struct classes. Maybe it would make sense to implement dumping/pretty-printing that way? (edit: re-reading @KOLANICH's comments above, I think that's what he was suggesting already.) If not, there's still no need to worry about name conflicts - just name the method |
Yep, I would prefer |
I could not find any docs on Python API. Are there any helpful methods beyond mere field accessors? For example, I need:
The text was updated successfully, but these errors were encountered: