lexonomy_editor_vsms/copy.py

25 lines
590 B
Python
Raw Normal View History

2019-03-06 22:32:02 +00:00
#!/usr/bin/python3
import base64
def copy(string):
import subprocess
subprocess.run(["xclip", "-selection", "c"], input=string, encoding='utf8')
with open("main.js", 'r') as fp:
script = fp.read()
with open("main.xslt", "r") as fp:
xslt = fp.read()
with open("hamburger.png", "rb") as fp:
img = fp.read()
with open("main.css", "r") as fp:
css = fp.read()
script = script.replace("XSLFILE", "`{}`".format(xslt))
script = script.replace("CSS", "`{}`".format(css))
script = script.replace("HAMBURGER", base64.b64encode(img).decode('ascii'))
copy(script)