Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Sharing pyui file is simplified by the following omz's script.
# This may be good enough if users just want to run the script.
# But if they want to see or edit the .pyui file, it would be helpful
# to generate the .pyui file. This script does this geneartion.
# This script extracts the encoded string, decode it and
# generate the .pyui file. Like the embedpyui script,
# this needs to be added to editor actions (wrench) menu.
import bz2
import re
from base64 import b64decode
import editor
import codecs
def main():
# get text between single triple quotes
# skip the first two characters, backslash and newline
data = re.split("""'''""", editor.get_text())[1][2:]
# decode as in omz's script and write it in .pyui file
pyui = bz2.decompress(b64decode(data))
filename = editor.get_path()[:-3] + '.pyui'
#print (filename)
with, "w", 'utf-8') as fp:
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment