#!/usr/local/bin/python

import os
import BOL

c = BOL.init_db("atraditions")


for file, name, ext in os.walk("."):
	code = file[2:]
	ext = [e[:-7] for e in ext if e.endswith("_sm.jpg")]
	print code
	print ext
	for ex in ext:
		type = ex[0:2]
		num = ex[2:]
		c.execute("select code from door_codes where type='%s' and door_code='%s'" %(type, code))
		d = c.fetchall()
		door_code = d[0][0]
		print door_code

		if (num.isdigit()):
			print ("insert into door_config values ('', %s, %s, '', '%s%s_sm.jpg', '%s%s_bg.jpg', '%s%s_zm.jpg')" %(door_code, num, type, num, type, num, type, num))
			c.execute("insert into door_config values ('', %s, %s, '', '%s%s_sm.jpg', '%s%s_bg.jpg', '%s%s_zm.jpg')" %(door_code, num, type, num, type, num, type, num))



