forked from agibli/sansapp
-
Notifications
You must be signed in to change notification settings - Fork 25
/
common.py
94 lines (59 loc) · 1.85 KB
/
common.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
import struct
def be_word4(buf):
return struct.unpack('>L', buf)[0]
def le_word4(buf):
return struct.unpack('<L', buf)[0]
def be_word8(buf):
return struct.unpack('>Q', buf)[0]
def le_word8(buf):
return struct.unpack('<Q', buf)[0]
def be_read4(stream):
return struct.unpack('>L', stream.read(4))[0]
def le_read4(stream):
return struct.unpack('<L', stream.read(4))[0]
def be_read8(stream):
return struct.unpack('>Q', stream.read(8))[0]
def le_read8(stream):
return struct.unpack('<Q', stream.read(8))[0]
def align(size, stride):
return stride * int(1 + ((size - 1) / stride))
def read_null_terminated(stream):
result = b''
next = stream.read(1)
while stream and next != b'\0':
result += next
next = stream.read(1)
return result
def plug_element_count(plug):
lbracket = plug.rfind(b'[')
if lbracket != -1:
rbracket = plug.rfind(b']')
if rbracket != -1 and lbracket < rbracket:
slicestr = plug[lbracket + 1:rbracket]
bounds = slicestr.split(b':')
if len(bounds) > 1:
return int(bounds[1]) - int(bounds[0]) + 1
return 1
class MayaParserBase(object):
def on_requires_maya(self, version):
pass
def on_requires_plugin(self, plugin, version):
pass
def on_file_info(self, key, value):
pass
def on_current_unit(self, angle, linear, time):
pass
def on_file_reference(self, path):
pass
def on_create_node(self, nodetype, name, parent):
pass
def on_select(self, name):
pass
def on_add_attr(self, node, name):
pass
def on_set_attr(self, name, value, type):
pass
def on_set_attr_flags(self, plug, keyable=None, channelbox=None, lock=None):
pass
def on_connect_attr(self, src_plug, dst_plug):
pass