Skip to content

Instantly share code, notes, and snippets.

@eljeko
Last active July 24, 2022 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eljeko/0b65134152302b9494975e9a68837277 to your computer and use it in GitHub Desktop.
Save eljeko/0b65134152302b9494975e9a68837277 to your computer and use it in GitHub Desktop.
MultiCharts pla file decoder converter script - Usage: python PlaDecoder.py <FILE_NAME>.pla
'''
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
'''
import xml.etree.ElementTree as xml
import sys
import base64
from os.path import exists
if (len(sys.argv) != 2):
print("usage: \n\t python PlaDecoder.py <FILE_NAME>.pla")
raise SystemExit
mFile = sys.argv[1]
if (not exists(mFile)):
print("File {} doesn't exists".format(mFile))
raise SystemExit
print("Decoding file >>> " + sys.argv[1])
tree = xml.ElementTree(file=sys.argv[1])
decoded = ""
for elt in tree.iter():
if (elt.tag == 'data'):
decoded += "Name [" + elt.attrib['first']+"] \n"
elif (elt.tag == 'NodeText'):
decoded += "Script Begin ==================================================================================== \n\n"
decoded += base64.b64decode(elt.text).decode('utf-8') + " \n"
decoded += "Script End ==================================================================================== \n\n"
outputFileName = file = sys.argv[1] + ".txt"
print("Writing decoded file >>> " + outputFileName)
f = open(outputFileName, "w")
f.write(decoded)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment