def save( path ):
	return USER_APPS.save( path, request.form[ 'content' ].encode( 'utf-8' ) )
def load( path ):
	return USER_APPS.send( path )
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the GNU General
# Public License for more details.
# 
# You should have received a copy of the GNU General Public License along with
# Learning-Week-2012-Software If not, see <http://www.gnu.org/licenses/>.

from xml.dom.minidom import parseString, Node

from flask import Blueprint, render_template, request, make_response
from werkzeug.exceptions import NotFound

from lwf import USER_APPS
from lwf.resources import Resources

xml = parseString( USER_APPS.load( 'applications.xml' ) )

def g0fcd( e, tag ):
	t = e.getElementsByTagName( tag )
	if t: return ( tag, t[ 0 ].firstChild.data )
	else: return None

USER_APPS_DESC = []
for g in xml.getElementsByTagName( 'group' ):
	group_name = g0fcd( g, 'name' )[ 1 ]
	apps = []
	for a in g.getElementsByTagName( 'application' ):
		app = dict( ( g0fcd( a, 'name' ), ) )
		app.update( { 
			'code': [ c.firstChild.data for c in a.getElementsByTagName( 'code' ) ],
			'output': [ o.firstChild.data for o in a.getElementsByTagName( 'output' ) ],
def save(path):
    return USER_APPS.save(path, request.form['content'].encode('utf-8'))
def load(path):
    return USER_APPS.send(path)
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# Learning-Week-2012-Software If not, see <http://www.gnu.org/licenses/>.

from xml.dom.minidom import parseString, Node

from flask import Blueprint, render_template, request, make_response
from werkzeug.exceptions import NotFound

from lwf import USER_APPS
from lwf.resources import Resources

xml = parseString(USER_APPS.load('applications.xml'))


def g0fcd(e, tag):
    t = e.getElementsByTagName(tag)
    if t: return (tag, t[0].firstChild.data)
    else: return None


USER_APPS_DESC = []
for g in xml.getElementsByTagName('group'):
    group_name = g0fcd(g, 'name')[1]
    apps = []
    for a in g.getElementsByTagName('application'):
        app = dict((g0fcd(a, 'name'), ))
        app.update({