Exemplo n.º 1
0
            out.write('%(delim)s-l%(lib)s' % names)
            delim = '\n%(tab)s               ' % names
        print
        out.write('"/>\n\n' % names)

    # Add headers
    
    for index, (path, headers) in enumerate(value['path'].items()):

        names['name'] = "%s%d" % (module, index)
        names['path'] = path
        names['tab'] = 2*TAB
        out.write('%(tab)s<headers name="%(name)s"\n'
                  '%(tab)s         basepath="%(path)s">\n' % names)

        for header in headers:
            names['header'] = header
            names['tab'] = 3*TAB    
            out.write('%(tab)s<header name="%(header)s"/>\n' % names)

        names['tab'] = 2*TAB
        out.write('%(tab)s</headers>\n\n' % names)

        names['tab'] = TAB
        out.write('%(tab)s</component>\n' % names)
            
out.write('</project>\n')
out.close()
#-----------------------------------------------------------------------------
print validateXmlFile("Project.xml")
Exemplo n.º 2
0
def projectAttributes(projectpath, attrib={}):

	returnAttrib = attrib == {}

	# Project Path

	attrib['projectpath'] = projectpath    
	if not os.path.exists("%(projectpath)s" % attrib):
		fatal("project path %s not found\n" % "%(projectpath)s" % attrib)


	# Project File Path    

	attrib['projectfile'] = NAMES['projectfile']
	attrib['projectfilepath'] = '%(projectpath)s/%(projectfile)s' % attrib    
	if not os.path.exists("%(projectfilepath)s" % attrib):
		fatal("project file %(projectfilepath)s not found\n" % attrib)

	# Load Project

	errstr = validateXmlFile("%(projectfilepath)s" % attrib)
	if errstr != '':
		fatal("\n%s" % errstr)

	project = readXmlFile("%(projectfilepath)s" % attrib)
	if project == None:
		fatal("Unable to read project\n"
			  "\t\tin file %(projectfilepath)s" % attrib)

	# Expand variables and re-read project file

	# Project Globals

	globals = project.findall('globals')
	if len(globals) > 0:
		attrib['globals'] = globals[0].attrib
	else:
		attrib['globals'] = {}

	record = expandNames(open("%(projectfilepath)s" % attrib).read(),
						 attrib['globals'])
	prjfile = '%(projectpath)s/config/.expandedProject.xml' % attrib
	open(prjfile,'w').write(record)
	project = readXmlFile(prjfile)
	if project == None:
		fatal("missing entity: project\n"
			  "\t\tin file %(projectfilepath)s" % attrib)

	attrib['project'] = project

	# Project preface(s) and appendix(s) 

	entity('preface', project, attrib, RESET, kind='list')
	entity('appendix', project, attrib, RESET, kind='list')

	# Project Name

	if project.attrib.has_key('name'):
		attrib['projectname'] = project.attrib['name']
	else:
		fatal("missing field: name\n"
			 "\t\tin project %(projectname)s\n"
			 "\t\t\tin file %(projectfilepath)" % attrib)

	# Project Version

	if project.attrib.has_key('version'):
		attrib['projectversion'] = project.attrib['version']
	else:
		attrib['projectversion'] = attrib['projectname']

	# Project Macros

	entity('macros', project, attrib, RESET, kind='map')

	# Project Options

	entity('options', project, attrib, RESET, kind='map')

	# Project Components

	components = project.findall('component')
	if len(components) == 0:
		fatal("project %(projectname)s must contain at least one component"
			  % attrib)

	attrib['components'] = {}
	attrib['componentnames'] = []

	# Loop over project components

	for component in components:

		if component.attrib.has_key('name'):
			componentname = component.attrib['name']
			attrib['componentnames'].append(componentname)
			attrib['components'][componentname] = component
		else:
			fatal("missing field: name\n"
				  "\t\tin component\n"
				  "\t\t\tin project %(projectname)s\n"
				  "\t\t\t\tin file %(projectfilepath)s" % attrib)

	if returnAttrib: return attrib
Exemplo n.º 3
0
            out.write('%(delim)s-l%(lib)s' % names)
            delim = '\n%(tab)s               ' % names
        print
        out.write('"/>\n\n' % names)

    # Add headers

    for index, (path, headers) in enumerate(value['path'].items()):

        names['name'] = "%s%d" % (module, index)
        names['path'] = path
        names['tab'] = 2 * TAB
        out.write('%(tab)s<headers name="%(name)s"\n'
                  '%(tab)s         basepath="%(path)s">\n' % names)

        for header in headers:
            names['header'] = header
            names['tab'] = 3 * TAB
            out.write('%(tab)s<header name="%(header)s"/>\n' % names)

        names['tab'] = 2 * TAB
        out.write('%(tab)s</headers>\n\n' % names)

        names['tab'] = TAB
        out.write('%(tab)s</component>\n' % names)

out.write('</project>\n')
out.close()
#-----------------------------------------------------------------------------
print validateXmlFile("Project.xml")