mirror of
https://gitea.cookies.4d.ink/Cookies/CookiesChartConverter.git
synced 2025-10-26 03:02:39 +00:00
34 lines
818 B
Python
34 lines
818 B
Python
import subprocess
|
|
import sys
|
|
from config import mcc
|
|
class MaichartConverterFailed(BaseException):
|
|
def __str__(self):
|
|
return "Maichart conversion failed."
|
|
|
|
def ma2tosimai(ma2path):
|
|
|
|
cmd = [
|
|
mcc,"CompileMa2","-p",
|
|
ma2path,
|
|
"-f","SimaiFes"
|
|
]
|
|
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
|
text = result.stdout
|
|
|
|
start_index = text.find("TargetFormat : SimaiFes")
|
|
|
|
# 如果找到了该字符串,提取后面的内容
|
|
if start_index != -1:
|
|
extracted_content = text[start_index + len("TargetFormat : SimaiFes"):].strip()
|
|
else:
|
|
extracted_content = ""
|
|
raise MaichartConverterFailed(result.stderr)
|
|
|
|
return extracted_content
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print(ma2tosimai(""))
|
|
|
|
|