#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os, fnmatch

svgfile = """#-*- coding: utf-8 -*-
# DO NOT EDIT THIS FILE MANUALLY, IT WILL GO AWAY!

embedsvg = {
"""
projectfolder = "appengine"
if not os.path.isdir( os.path.join(".","..", projectfolder)):
	projectfolder = "deploy"

basepath = os.path.join(".","..", projectfolder,"viur","vi")
#print(basepath)
for dir in [os.path.join(basepath, "public","embedsvg")]:
	try:
		svgs = fnmatch.filter(os.listdir(dir), "*.svg")
	except OSError:
		continue

	for svg in svgs:
		key = svg[:-4]
		svgfile+="\tu\"\"\"{}\"\"\": u\"\"\"{}\"\"\",\n".format(key, open(os.path.join(dir, svg), "r").read())
svgfile+="}"

try:
	os.makedirs(basepath)
except:pass
#print( os.path.abspath(basepath))

f = open(os.path.join(basepath,"embedsvg.py"),"w")
f.write(svgfile)
f.close()
