You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-99Lines changed: 23 additions & 99 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,17 +84,17 @@ Converts a list of integers into a byte.
84
84
85
85
Converts bytes object *b* into an integer. The endian can be specified with the *endian* argument. The *signed* argument is used to specify whether the integer is signed or not.
Converts *number* into a bytes object with length *numbytes* and endian *endian*. The *signed* argument is used to specify whether the integer is signed or not.
89
+
Converts *number* into a bytes object with length *size* and endian *endian*. The *signed* argument is used to specify whether the integer is signed or not.
90
90
91
-
**unpack_float(b, numbytes, endian=None)**
91
+
**unpack_float(b, size, endian=None)**
92
92
93
-
Converts bytes object *b* into a float. *numbytes* can be 2 for half precision, 4 for single precision, or 8 for double precision. The endian can be specified with the *endian* argument.
93
+
Converts bytes object *b* into a float. *size* can be 2 for half precision, 4 for single precision, or 8 for double precision. The endian can be specified with the *endian* argument.
94
94
95
-
**pack_float(number, numbytes, endian=None)**
95
+
**pack_float(number, size, endian=None)**
96
96
97
-
Converts *number* into a bytes object. *numbytes* can be 2 for half precision, 4 for single precision, or 8 for double precision. The endian can be specified with the *endian* argument.
97
+
Converts *number* into a bytes object. *size* can be 2 for half precision, 4 for single precision, or 8 for double precision. The endian can be specified with the *endian* argument.
98
98
99
99
**unpack_str(b)**
100
100
@@ -112,13 +112,13 @@ Convert bytes object *b* into a string up to the null termination. If *start* is
112
112
113
113
Converts *string* into a bytes object representing a null-terminated string.
Converts bytes object *b* into a Pascal string. *numbytes* is used to specify how many bytes are used for the string's length in the object. The endian of the length of the string can be specified with the *endian* argument. *b* will only be converted up to the length specified in the bytes object. If *start* is specified, then the bytes object will be converted starting from position *start*. Returns a tuple containing both the value and the length of the type.
117
+
Converts bytes object *b* into a Pascal string. *size* is used to specify how many bytes are used for the string's length in the object. The endian of the length of the string can be specified with the *endian* argument. *b* will only be converted up to the length specified in the bytes object. If *start* is specified, then the bytes object will be converted starting from position *start*. Returns a tuple containing both the value and the length of the type.
118
118
119
-
**pack_pstr(string, numbytes, endian=None)**
119
+
**pack_pstr(string, size, endian=None)**
120
120
121
-
Converts *string* into a bytes object in the Pascal string format. *numbytes* is used to specify how many bytes are used for the string's length. The endian of the length of the string can be specified with the *endian* argument.
121
+
Converts *string* into a bytes object in the Pascal string format. *size* is used to specify how many bytes are used for the string's length. The endian of the length of the string can be specified with the *endian* argument.
122
122
123
123
**unpack_7bint(b, start=0)**
124
124
@@ -158,10 +158,6 @@ Returns the size/length of the file.
158
158
159
159
Checks if the content of the object is equal to the content of another instance of the same object.
160
160
161
-
**is_eof()**
162
-
163
-
Return True if the end of the stream has been reached.
164
-
165
161
**copy()**
166
162
167
163
Creates a copy of the object and returns it.
@@ -170,18 +166,6 @@ Creates a copy of the object and returns it.
170
166
171
167
Clear the internal buffer of the object.
172
168
173
-
**append(b)**
174
-
175
-
Appends bytes object *b* to the object at the current location.
176
-
177
-
**overwrite(self, length, b)**
178
-
179
-
Overwrites *length* bytes at the current position with *b*.
180
-
181
-
**delete(length)**
182
-
183
-
Deletes *length* bytes from the object starting from the current position.
184
-
185
169
**find(bytes_sequence, n=1)**
186
170
187
171
Searches the object for *bytes_sequence*. Returns the location in which the *nth* occurrence of *bytes_sequence* can be found, returns -1 if it's not found. Starts searching from the current position in the buffer.
@@ -198,10 +182,6 @@ Read one byte from the object and converts it into a boolean.
198
182
199
183
Writes *boolean* to the object.
200
184
201
-
**append_bool()**
202
-
203
-
Appends *boolean* to the object.
204
-
205
185
**read_bits()**
206
186
207
187
Reads one byte from the object and converts it into a list of integers representing the individual bits in the byte. The first element in the list is LSB in the byte.
@@ -210,33 +190,21 @@ Reads one byte from the object and converts it into a list of integers represent
210
190
211
191
Converts list of integers *bits* into a byte and writes it to the object.
212
192
213
-
**append_bits(bits)**
193
+
**read_int(size, endian=None, signed=False)**
214
194
215
-
Converts list of integers *bits* into a byte and writes it to the object.
216
-
217
-
**read_int(numbytes, endian=None, signed=False)**
218
-
219
-
Reads *numbytes* bytes from the object and converts it into an integer. The endian can be specified with the *endian* argument. The *signed* argument is used to specify whether the integer is signed or not.
Converts *number* into a bytes object with length *numbytes* and endian *endian*, then writes it into the object. The *signed* argument is used to specify whether the integer is signed or not.
195
+
Reads *size* bytes from the object and converts it into an integer. The endian can be specified with the *endian* argument. The *signed* argument is used to specify whether the integer is signed or not.
Same as *write_int* but appends the value to the object at the current position instead of overwriting existing bytes.
199
+
Converts *number* into a bytes object with length *size* and endian *endian*, then writes it into the object. The *signed* argument is used to specify whether the integer is signed or not.
228
200
229
-
**read_float(numbytes, endian=None)**
201
+
**read_float(size, endian=None)**
230
202
231
-
Reads *numbytes* bytes from the object and converts them into a float. *numbytes* can be 2 for half precision, 4 for single precision, or 8 for double precision. The endian can be specified with the *endian* argument.
203
+
Reads *size* bytes from the object and converts them into a float. *size* can be 2 for half precision, 4 for single precision, or 8 for double precision. The endian can be specified with the *endian* argument.
232
204
233
-
**write_float(number, numbytes, endian=None)**
205
+
**write_float(number, size, endian=None)**
234
206
235
-
Converts *number* into a bytes object then writes it into the object. *numbytes* can be 2 for half precision, 4 for single precision, or 8 for double precision. The endian can be specified with the *endian* argument.
236
-
237
-
**append_float(number, numbytes, endian=None)**
238
-
239
-
Same as *write_float* but appends the value to the object at the current position instead of overwriting existing bytes. *numbytes* can be 2 for half precision, 4 for single precision, or 8 for double precision. The endian can be specified with the *endian* argument.
207
+
Converts *number* into a bytes object then writes it into the object. *size* can be 2 for half precision, 4 for single precision, or 8 for double precision. The endian can be specified with the *endian* argument.
240
208
241
209
**read_str(length)**
242
210
@@ -246,14 +214,6 @@ Reads a string with length *length* from the object.
246
214
247
215
Writes *string* into the object.
248
216
249
-
**append_str(string)**
250
-
251
-
Same as *write_str* but appends the value to the object at the current position instead of overwriting existing bytes.
252
-
253
-
**overwrite_str(string, length)**
254
-
255
-
Deletes *length* bytes starting from the current location, then writes *string* in it's place.
256
-
257
217
**read_cstr()**
258
218
259
219
Reads a string from the object up to the null termination. Raises a *ValueError* if it fails to find a null termination.
@@ -262,46 +222,22 @@ Reads a string from the object up to the null termination. Raises a *ValueError*
262
222
263
223
Writes *string* into the object.
264
224
265
-
**append_cstr(string)**
266
-
267
-
Same as *write_cstr* but appends the value to the object at the current position instead of overwriting existing bytes.
268
-
269
-
**overwrite_cstr(string)**
270
-
271
-
Deletes the null-terminated string existing at the current location, then writes *string* as a null-terminated string in it's place. Raises a *ValueError* if it fails to find a null termination.
272
-
273
225
**skip_cstr()**
274
226
275
227
Skips the null-terminated string at the current position.
276
228
277
-
**delete_cstr()**
229
+
**read_pstr(size, endian=None)**
278
230
279
-
Deletes the null-terminated string at the current position.
231
+
Reads a Pascal string from the object and returns it. *size* is used to specify how many bytes are used for the string's length in the object. The endian of the length of the string can be specified with the *endian* argument.
280
232
281
-
**read_pstr(numbytes, endian=None)**
282
-
283
-
Reads a Pascal string from the object and returns it. *numbytes* is used to specify how many bytes are used for the string's length in the object. The endian of the length of the string can be specified with the *endian* argument.
284
-
285
-
**write_pstr(string, numbytes, endian=None)**
233
+
**write_pstr(string, size, endian=None)**
286
234
287
235
Writes *string* to the object as a Pascal string.
288
236
289
-
**append_pstr(string, numbytes, endian=None)**
290
-
291
-
Same as *write_pstr* but appends the value to the object at the current position instead of overwriting existing bytes.
292
-
293
-
**overwrite_pstr(string, numbytes, endian=None)**
294
-
295
-
Deletes the existing Pascal string at the current position and writes *string* as a Pascal string in it's place.
296
-
297
-
**skip_pstr(numbytes, endian=None)**
237
+
**skip_pstr(size, endian=None)**
298
238
299
239
Skips the Pascal string at the current position.
300
240
301
-
**delete_pstr(numbytes, endian=None)**
302
-
303
-
Deletes the Pascal string at the current position.
304
-
305
241
**read_7bint()**
306
242
307
243
Reads the bytes representing a 7 bit integer from the object at the current position and converts them into an integer.
@@ -310,18 +246,6 @@ Reads the bytes representing a 7 bit integer from the object at the current posi
310
246
311
247
Converts *number* into a 7 bit integer and writes it to the object.
312
248
313
-
**append_7bint(number)**
314
-
315
-
Converts *number* into a 7 bit integer and appends it to the object.
316
-
317
-
**overwrite_7bint(number)**
318
-
319
-
Overwrites the 7 bit integer at the current position with *number*.
320
-
321
249
**skip_7bint()**
322
250
323
-
Skips the 7 bit integer at the current position.
324
-
325
-
**delete_7bint()**
326
-
327
-
Deletes the 7 bit integer at the current position.
0 commit comments