Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
temp = namedValueLookup.get(oValue.id)
if temp is not None:
myParams[index] = int(temp)
else:
buttonstr = oValue.id[-1]
directionstr = oValue.id[:-1]
myParams[index] = (int(namedButtonLookup[buttonstr]) << 8) + int(namedDirectionLookup[directionstr])
else:
raise Exception("Unknown Type" + str(type(oValue)))
output.write(struct.pack(MODE+"I",id))
if "format" in cmdData:
output.write(struct.pack(MODE+cmdData["format"],*myParams))
elif cmdData["size"] > 4:
output.write(myParams[0].decode('hex'))
class Rebuilder(astor.ExplicitNodeVisitor):
def visit_Module(self,node):
global output
global root
root = node
stateCount = 0
output.write(struct.pack(MODE+"I",stateCount))
for function in node.body:
if type(function) != FunctionDef:
raise Exception("Root level elements must be functions")
if function.decorator_list[0].id != "State":
continue
function._index = stateCount
stateCount += 1
if function.name.startswith('__') and function.name[2].isdigit():
function.name = function.name[2:]
if '__sp__' in function.name:
myParams[index] = oValue.n
# elif isinstance(oValue,Name):
# myParams[index] = int(namedValueLookup[oValue.id])
else:
raise Exception("Unknown Type" + str(type(oValue)))
output.write(struct.pack(MODE+"I",id))
if cmdData.get('format', "notempty") == "":
return
if cmdData.get('size', 5) == 4:
return
if "format" in cmdData:
output.write(struct.pack(MODE+cmdData["format"],*myParams))
else:
output.write(myParams[0].decode('hex'))
class Rebuilder(astor.ExplicitNodeVisitor):
def visit_Module(self,node):
global output
global root
root = node
stateCount = 0
futtobiBGTransVisited = False
cmnActLoseVisited = False
output.write(struct.pack(MODE+"I",stateCount))
for function in node.body:
if type(function) != FunctionDef:
raise Exception("Root level elements must be functions")
if function.name[:2] == '__' and function.name[2].isdigit():
function.name = function.name[2:]
if function.decorator_list[0].id != "State":
continue
if function.name == "CmnActFuttobiBGTrans" and not futtobiBGTransVisited:
myParams[index] = oValue.n
elif isinstance(oValue,Name):
myParams[index] = int(named_value_lookup.value_for_name(commandDB[str(id)]["name"], oValue.id))
else:
raise Exception("Unknown Type" + str(type(oValue)))
output.write(struct.pack(MODE+"I",id))
if cmdData.get('format', "notempty") == "":
return
if cmdData.get('size', 5) == 4:
return
if "format" in cmdData:
output.write(struct.pack(MODE+cmdData["format"],*myParams))
else:
output.write(myParams[0].decode('hex'))
class Rebuilder(astor.ExplicitNodeVisitor):
def visit_Module(self,node):
global output
global root
root = node
stateCount = 0
output.write(struct.pack(MODE+"I",stateCount))
for function in node.body:
if type(function) != FunctionDef:
raise Exception("Root level elements must be functions")
if function.name[:2] == '__' and function.name[2].isdigit():
function.name = function.name[2:]
if function.decorator_list[0].id != "State":
continue
function._index = stateCount
stateCount += 1
output.write(struct.pack(MODE+"32sI",function.name,0xFADEF00D))
pass
elif isinstance(oValue,float):
pass
elif isinstance(oValue,Str):
myParams[index] = oValue.s
elif isinstance(oValue,Num):
myParams[index] = oValue.n
else:
raise Exception("Unknown Type" + str(type(oValue)))
output.write(struct.pack(MODE+"I",id))
if "format" in cmdData:
output.write(struct.pack(MODE+cmdData["format"],*myParams))
else:
output.write(myParams[0].decode('hex'))
class Rebuilder(astor.ExplicitNodeVisitor):
def visit_Module(self,node):
global output
global root
root = node
stateCount = 0
output.write(struct.pack(MODE+"I",stateCount))
for function in node.body:
if type(function) != FunctionDef:
raise Exception("Root level elements must be functions")
if function.decorator_list[0].id != "State":
continue
function._index = stateCount
stateCount += 1
output.write(struct.pack(MODE+"32sI",function.name,0xFADEF00D))
node._dataStart = output.tell()
output.seek(0)