75 lines
2.5 KiB
Python
75 lines
2.5 KiB
Python
import MathMethod
|
|
import binascii
|
|
import tools
|
|
import shlex
|
|
import json
|
|
import fio
|
|
import re
|
|
import os
|
|
|
|
def is_in(json,key):
|
|
if key in json:
|
|
return True
|
|
else:
|
|
return False
|
|
def is_kin(list,index):
|
|
if 0 <= index < len(list):
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
#基本读取
|
|
read=fio.openr("./PyBase.cpsm")
|
|
pybasecode=binascii.hexlify(read.encode('utf-8'))
|
|
|
|
_IStart={"VERSION":"3.7.5","MAIN":".主函数"}
|
|
|
|
#获取所有头内容(.Start)
|
|
_=MathMethod.GetFlatDivision(read,"[声明完成]",0)
|
|
_=MathMethod.GetCarriageSpacesSmooth(_)
|
|
_=MathMethod.GetBeforeAfterRuleLookup(_,"[","]")
|
|
_Start=MathMethod.GetRulesConvertedToJson(_,"[","]")
|
|
if is_in(_Start,"声明类型"):
|
|
if is_kin(_Start["声明类型"],0):
|
|
if _Start["声明类型"][0].lower() == "蟒蛇汇编中文":
|
|
pass
|
|
else:
|
|
print("- * - Error: [声明类型] isn't pybase")
|
|
os._exit(0)
|
|
else:
|
|
print("- * - Error: [声明类型] isn't be <Key>")
|
|
os._exit(0)
|
|
else:
|
|
print("- * - Error: There is no [声明类型]")
|
|
os._exit(0)
|
|
if is_in(_Start,"声明版本"):
|
|
if is_kin(_Start["声明版本"],0):
|
|
if len(_Start["声明版本"][0]) <= 10:
|
|
_IStart["声明版本"]=_Start["声明版本"][0]
|
|
else:
|
|
print("- * - Warning: [声明版本] len(<Key>) > 10")
|
|
else:
|
|
print("- * - Warning: [声明版本] isn't be <Key>")
|
|
else:
|
|
print("- * - Warning: There is no [声明版本]")
|
|
if is_in(_Start,"声明入口"):
|
|
if is_kin(_Start["声明入口"],0):
|
|
_IStart["声明入口"]=_Start["声明入口"][0]
|
|
print("- * - InFo: [声明入口] .声明入口 -> "+_Start["声明入口"][0])
|
|
else:
|
|
print("- * - Warning: [声明入口] isn't be <Key>(Use .声明入口)")
|
|
else:
|
|
print("- * - Warning: There is no [声明入口](Use .声明入口)")
|
|
#获取所有代码内容(.Code)
|
|
_=MathMethod.GetFlatDivision(read,"[声明完成]",1,lambda x:x,"")
|
|
_Code=MathMethod.AssemblyToJson(_,MakeRules=lambda x:MathMethod.GetRulesConvertedToJson2(x))
|
|
|
|
print(_Code)
|
|
|
|
#编译(甚至不需要分析意思)
|
|
_Base=bytes()
|
|
_Base+=bytes.fromhex("0020"*2+"507942617365"+"AA"*5+"00")
|
|
_Base+=bytes.fromhex("5468697320697320612070726F6772616D20746861742063616E206265206C61756E63686564206279205079426173650A")
|
|
_Base+=bytes.fromhex(binascii.hexlify(_IStart["VERSION"].rjust(10).encode()).decode())
|
|
_Base+=bytes.fromhex(binascii.hexlify(tools.CBDS(str(_Code))).decode())
|
|
fio.openw("./PyBase.Bin",_Base,2) |