예제 #1
0
파일: __init__.py 프로젝트: revilor/BOLTS
def get_identical_links(cl,prt):
	identical = []
	if repo.class_standards.contains_src(cl):
		for s in repo.class_standards.get_dsts(cl):
			if s is prt:
				continue
			identical.append(html.a(s.standard.get_nice(),href=url_for('.standard',id=s.get_id())))
	if repo.class_names.contains_src(cl):
		for n in repo.class_names.get_dsts(cl):
			if n is prt:
				continue
			identical.append(html.a(gettext_parts(n.name.get_nice()),href=url_for('.name',id=n.get_id())))
	return identical
예제 #2
0
파일: __init__.py 프로젝트: revilor/BOLTS
def name(id):
	name = repo.names[id]
	cl = repo.class_names.get_src(name)
	coll = repo.collection_names.get_src(name)

	#properties
	props = []
	props.append(format_author_prop(coll.author_names))
	props.append((gettext('License'),html.a(coll.license_name,href=coll.license_url)))
	props.append((gettext('Collection'),html.a(coll.name,href=url_for('.collection',id=coll.id))))

	identical = get_identical_links(cl,name)
	if len(identical) > 0:
		props.append((gettext('Identical to'),', '.join(identical)))

	if not cl.url == "":
		props.append(('URL',cl.url))
	props.append(('ID',name.get_id()))
	props.append((gettext('Source'),cl.source))

	#parameters
	parameters = {}
	parameters["tables"] = []
	for table in utils.tables_as_dicts(cl.parameters):
		table["class"] = "table"
		parameters["tables"].append(html.table(table))

	parameters["tables2d"] = []
	for table in utils.tables2d_as_dicts(cl.parameters):
		table["class"] = "table"
		parameters["tables2d"].append(html.table2d(table))

	parameters["drawing"] = None
	if dbs["drawings"].dimdrawing_classes.contains_dst(cl):
		draw = dbs["drawings"].dimdrawing_classes.get_src(cl)
		parameters["drawing"] = url_for('.drawing',coll=coll.id,filename = "%s.png" % draw.filename)

	parameters["description"] = html.table({
		"header" : [gettext("Parameter Name"),gettext("Description")],
		"data" : [[p,gettext_parts(cl.parameters.description[p])] for p in cl.parameters.parameters],
		"class" : "table"
	})

	#freecad
	freecad = {}
	if dbs["freecad"].base_classes.contains_dst(cl):
		base = dbs["freecad"].base_classes.get_src(cl)

		freecad["props"] = []
		freecad["props"].append(format_author_prop(base.author_names))
		freecad["props"].append((gettext('License'),html.a(base.license_name,href=base.license_url)))
		freecad["props"] = html.properties(freecad["props"])
	else:
		freecad = None

	#openscad
	openscad = {}
	if dbs["openscad"].module_classes.contains_dst(cl):
		module = dbs["openscad"].module_classes.get_src(cl)

		openscad["props"] = []
		openscad["props"].append(format_author_prop(module.author_names))
		openscad["props"].append((gettext('License'),html.a(module.license_name,href=module.license_url)))
		openscad["props"] = html.properties(openscad["props"])

		params = cl.parameters.union(module.parameters)
		openscad["incantation_module"] = "module %s(%s)" % (name.get_id(),get_signature(params))
		openscad["incantation_dims"] = "function %s_dims(%s)" % (name.get_id(),get_signature(params))
		openscad["incantation_conn"] = "function %s_conn(location,%s)" % (name.get_id(),get_signature(params))
		

		if dbs["openscad"].module_connectors.contains_src(module):
			connectors = dbs["openscad"].module_connectors.get_dst(module)
			conns = []
			for loc in connectors.locations:
				if not dbs["drawings"].conlocations_condrawings.contains_src(loc):
					continue
				for draw in dbs["drawings"].conlocations_condrawings.get_dsts(loc):
					if cl in dbs["drawings"].condrawings_classes.get_dsts(draw):
						draw_url = url_for('.drawing',coll=coll.id,filename = "%s.png" % draw.filename)
						conns.append([loc,html.a(html.img(src=draw_url,width="200"),href=draw_url)])

			openscad["connectors"] = html.table({
					"header" : [gettext("Location"),gettext("Drawing")],
					"class" : "table",
					"data" : conns})
		else:
			openscad["connectors"] = None
	else:
		openscad = None



	page = {"title" : "Part list"}
	return render_template("parts/name.html",
		page = page,
		name = name,
		props = html.properties(props),
		parameters = parameters,
		freecad = freecad,
		openscad = openscad
		)