#!/usr/bin/env python

NOFLAG = 0
PINFLAG = 1
VIAFLAG = 2
HOLEFLAG = 8
DISPLAYNAMEFLAG = 0x20
SQUAREFLAG = 0x0100
USETHERMALFLAG = 0x0400
OCTAGONFLAG = 0x0800

class Standin(object):
	def __init__(self, operator):
		self.operator = operator
	def __getitem__(self, item):
		print("GI", item)
		pass
	def __call__(self, *args):
		pass
elementStandin = Standin("Element")
pinStandin = Standin("Pin")
elementLineStandin = Standin("ElementLine")

def load(f):
	data = f.read()
	eval(data, {
		"Element": elementStandin,
		"Pin": pinStandin,
		"ElementLine": elementLineStandin,
	})
	elementLine = f.readline()
	n, rest = elementLine.split("(", 1)
	assert(n == "Element")
	


if __name__ == "__main__":
	import StringIO
	s = StringIO.StringIO(
	"""Element(0x00000000 "" "R11" "" 1800 1050 56 -138 0 100 0x00000000)
(
	Pin(0 0 60 30 60 28 "" "1" 0x00000001)
	Pin(0 -300 60 30 60 28 "" "2" 0x00000001)
	ElementLine (0 -50 0 -90 10)
	ElementLine (40 -90 -40 -90 10)
	ElementLine (-40 -90 -40 -210 10)
	ElementLine (-40 -210 40 -210 10)
	ElementLine (40 -210 40 -90 10)
	ElementLine (0 -210 0 -250 10)
	)""")
	print(load(s))

	"""
Element (element_flags,  description,  pcb-name,  value,  
mark_x,  mark_y,  text_x,  text_y,
        text_direction,  text_scale,  text_flags)
(
individual graphical components, such as Pad, Pin, 
or ElementLine.
)
	"""
	pass

