This repository has been archived by the owner on Dec 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathstruct.py
106 lines (76 loc) · 2.33 KB
/
struct.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
"""Skeleton for 'struct' stdlib module."""
from __future__ import unicode_literals
import sys
def pack(fmt, *values):
"""Return a string containing the values packed according to the given
format.
:type fmt: bytes | unicode
:rtype: bytes
"""
return b''
def unpack(fmt, string):
"""Unpack the string according to the given format.
:type fmt: bytes | unicode
:type string: bytestring
:rtype: tuple
"""
pass
def pack_into(fmt, buffer, offset, *values):
""""Pack the values according to the given format, write the packed
bytes into the writable buffer starting at offset.
:type fmt: bytes | unicode
:type offset: int | long
:rtype: bytes
"""
return b''
def unpack_from(fmt, buffer, offset=0):
"""Unpack the buffer according to the given format.
:type fmt: bytes | unicode
:type offset: int | long
:rtype: tuple
"""
pass
def calcsize(fmt):
"""Return the size of the struct (and hence of the string) corresponding to
the given format.
:type fmt: bytes | unicode
:rtype: int
"""
return 0
class Struct(object):
"""Struct object which writes and reads binary data according to the format
string.
:param format: The format string used to construct this Struct object.
:type format: bytes | unicode
:param size: The calculated size of the struct corresponding to format.
:type size: int
"""
def __init__(self, format):
"""Create a new Struct object.
:type format: bytes | unicode
"""
self.format = format
self.size = 0
def pack(self, *values):
"""Identical to the pack() function, using the compiled format.
:rtype: bytes
"""
return b''
def pack_into(self, buffer, offset, *values):
"""Identical to the pack_into() function, using the compiled format.
:type offset: int | long
:rtype: bytes
"""
return b''
def unpack(self, string):
"""Identical to the unpack() function, using the compiled format.
:type string: bytestring
:rtype: tuple
"""
pass
def unpack_from(self, buffer, offset=0):
"""Identical to the unpack_from() function, using the compiled format.
:type offset: int | long
:rtype: tuple
"""
pass