def create_logical_model_with_supplements_index_page(): import airm airm = airm.Airm() airm_logical_concepts = airm.logical_concepts.to_dict('records') airm_logical_concepts_supp = airm.logical_supp_concepts.to_dict('records') template = open( "docs/airm/templates/viewer/logical-model-with-supplements-template.html" ).read() from bs4 import BeautifulSoup soup = BeautifulSoup(template, "lxml") for record in airm_logical_concepts: directory = "logical-model/" soup.find('tbody').insert( 1, create_index_row_logical_model_with_supplements(record, directory)) for record in airm_logical_concepts_supp: directory = "logical-model/european-supplement/" soup.find('tbody').insert( 1, create_index_row_logical_model_with_supplements(record, directory)) f = open("docs/airm/viewer/1.0.0/logical-model-with-supplements.html", "w+") f.write(soup.prettify()) f.close()
def test_menu(): """Print the testing menu and wait for a selection.""" choice = '0' while choice == '0': print("Testing menu: ") print('') print("1: Test airm.urn_to_url(urn)") print('') print("2: Test airm.get_concept(urn)") print('') print("99: main menu") print('') choice = input("Please make a choice: ") print('') if choice == "1": print('\n') urn = input("Paste a urn: ") import airm print(airm.urn_to_url(urn)) test_menu() elif choice == "2": print('\n') urn = input("Paste a urn: ") import airm airm = airm.Airm() print(airm.get_concept(urn)) test_menu() elif choice == "99": main_menu()
def create_logical_model_item_pages(): import airm airm = airm.Airm() airm_logical_concepts = airm.logical_concepts.to_dict('records') airm_logical_concepts_supp = airm.logical_supp_concepts.to_dict('records') for record in airm_logical_concepts_supp: template = open( "docs/airm/templates/viewer/logical-model/european-supplement/logical-model-concept-template.html" ).read() scope = "european-supplement/" children = airm.get_children_for_logical_model_class( record["urn"], scope) create_logical_model_item_page(record, template, scope, children) for record in airm_logical_concepts: template = open( "docs/airm/templates/viewer/logical-model/logical-model-concept-template.html" ).read() scope = "" children = airm.get_children_for_logical_model_class( record["urn"], scope) supplements = airm.get_supplements_for_logical_model_class( record["urn"]) create_logical_model_item_page(record, template, scope, children, supplements)
def create_contextual_model_abbreviations_with_supplements_index_page(): import airm airm = airm.Airm() airm_abbreviations = airm.contextual_abbreviations.to_dict('records') template = open( "docs/airm/templates/viewer/contextual-model-abbreviations-with-supplements-template.html" ).read() from bs4 import BeautifulSoup soup = BeautifulSoup(template, "lxml") for record in airm_abbreviations: if record["supplement"] == "\t\t\t": directory = "contextual-model/" soup.find('tbody').insert( 1, create_index_row_with_supplements(record, directory)) elif record["supplement"] == "\t\t\tEuropean Supplement": directory = "contextual-model/european-supplement/" soup.find('tbody').insert( 1, create_index_row_with_supplements(record, directory)) f = open( "docs/airm/viewer/1.0.0/contextual-model-abbreviations-with-supplements.html", "w+") f.write(soup.prettify()) f.close()
def create_contextual_model_abbreviations_item_pages(): import airm airm = airm.Airm() airm_abbs = airm.contextual_abbreviations.to_dict('records') for record in airm_abbs: if record["supplement"] == "\t\t\t": template = open( "docs/airm/templates/viewer/contextual-model/contextual-model-abbreviation-template.html" ).read() directory = "docs/airm/viewer/1.0.0/contextual-model/" elif record["supplement"] == "\t\t\tEuropean Supplement": template = open( "docs/airm/templates/viewer/contextual-model/european-supplement/contextual-model-abbreviation-template.html" ).read() directory = "docs/airm/viewer/1.0.0/contextual-model/european-supplement/" from bs4 import BeautifulSoup soup = BeautifulSoup(template, "lxml") print(record['class name']) soup.title.string = str( record['class name']) + " - Contextual Model | AIRM.aero" soup.find(text="CONCEPT_NAME_BC").replace_with( str(record['class name'])) h2 = soup.new_tag("h2") h2.string = str(record['class name']) span_supplement = soup.new_tag("spam") if record["supplement"] == "\t\t\tEuropean Supplement": span_supplement['class'] = "badge badge-secondary" span_supplement.string = "European Supplement" h2.insert(1, span_supplement) soup.find(id="INFO_CONCEPT_NAME").insert(0, h2) code = soup.new_tag("code") code.string = record['urn'] code["class"] = "text-secondary" soup.find(id="INFO_CONCEPT_NAME").insert(1, code) soup.find(text="CONCEPT_DEFINITION").replace_with( str(record['definition'])) p = soup.new_tag("p") p.string = "Source: " span = soup.new_tag("span") span.string = record["source"] p.insert(2, span) soup.find(id="DATA_CONCEPTS_DETAIL").insert(1, p) filename = classname_to_filename(str(record['class name'])) f = open(directory + filename, "w+") f.write(soup.prettify()) f.close()
def create_conceptual_model_index_page(): import airm airm = airm.Airm() airm_concepts = airm.conceptual_concepts.to_dict('records') template = open( "docs/airm/templates/viewer/conceptual-model-template.html").read() from bs4 import BeautifulSoup soup = BeautifulSoup(template, "lxml") directory = "conceptual-model/" for record in airm_concepts: if record["supplement"] == "\t\t\t": soup.find('tbody').insert(1, create_index_row(record, directory)) f = open("docs/airm/viewer/1.0.0/conceptual-model.html", "w+") f.write(soup.prettify()) f.close()
def create_conceptual_model_item_pages(): import airm airm = airm.Airm() airm_concepts = airm.conceptual_concepts.to_dict('records') airm_concepts_supp = airm.conceptual_supp_concepts.to_dict('records') for record in airm_concepts_supp: template = open( "docs/airm/templates/viewer/conceptual-model/european-supplement/conceptual-model-concept-template.html" ).read() scope = "european-supplement/" create_conceptual_model_item_page(record, template, scope) for record in airm_concepts: template = open( "docs/airm/templates/viewer/conceptual-model/conceptual-model-concept-template.html" ).read() scope = "" create_conceptual_model_item_page(record, template, scope)
def create_semantic_correspondence_table(data_concept): """Return an html table containing the semantic correspondence for a data concept. Keyword arguments: data_concept -- A dictionary containing the data concept. """ from bs4 import BeautifulSoup soup = BeautifulSoup("<b></b>", 'lxml') sc_table = soup.new_tag("table") sc_table["class"] = "table" sc_thead = soup.new_tag("thead") tr = soup.new_tag("tr") th = soup.new_tag("th") th.string = "AIRM Concept" tr.insert(1, th) th = soup.new_tag("th") th.string = "Definition" tr.insert(2, th) sc_thead.insert(1, tr) sc_table.insert(1, sc_thead) tbody = soup.new_tag("tbody") insert_position = 0 if str(data_concept['AIRM Concept Identifier']) != "missing data": import airm airm = airm.Airm() urns = str(data_concept['AIRM Concept Identifier']).split('\n') for urn in urns: airm_concept = airm.get_concept(urn) if airm_concept != None: tr = soup.new_tag("tr") td = soup.new_tag("td") a = soup.new_tag("a") a['href'] = relativise_url(airm_concept['url']) a['target'] = "_blank" a.string = airm_concept['name'] td.insert(1, a) tr.insert(1, td) td = soup.new_tag("td") td.string = airm_concept['definition'] tr.insert(2, td) tbody.insert(insert_position, tr) insert_position += 1 if str(data_concept['Additional Traces']) != "missing data": import airm airm = airm.Airm() urns = str(data_concept['Additional Traces']).split('\n') for urn in urns: airm_concept = airm.get_concept(urn) if airm_concept != None: tr = soup.new_tag("tr") td = soup.new_tag("td") spam = soup.new_tag("spam") spam["class"] = "badge badge-secondary" spam["data-toggle"] = "tooltip" spam["data-placement"] = "bottom" spam[ "title"] = "Additional traces to clarify the mapping of narrower concepts" spam.string = "Additional trace" td.insert(1, spam) a = soup.new_tag("a") a['href'] = relativise_url(airm_concept['url']) a['target'] = "_blank" a.string = airm_concept['name'] td.insert(2, a) tr.insert(1, td) td = soup.new_tag("td") td.string = airm_concept['definition'] tr.insert(2, td) tbody.insert(insert_position, tr) insert_position += 1 if str(data_concept['Special cases \n(CR, OutOfScope, Not Established)'] ) != "missing data": import airm airm = airm.Airm() parts = str( data_concept['Special cases \n(CR, OutOfScope, Not Established)'] ).split('\n') for case in parts: airm_concept = airm.get_concept(case) if airm_concept != None: tr = soup.new_tag("tr") td = soup.new_tag("td") a = soup.new_tag("a") a['href'] = relativise_url(airm_concept['url']) a['target'] = "_blank" a.string = airm_concept['name'] td.insert(1, a) tr.insert(1, td) td = soup.new_tag("td") td.string = airm_concept['definition'] tr.insert(2, td) tbody.insert(insert_position, tr) insert_position += 1 sc_table.insert(2, tbody) return sc_table
def old_create_html(): import airm airm = airm.Airm() #configuration json_mapping_file = "data/json/fixm-mapping.json" #assets/js/fixm-mapping-test.json OR assets/js/fixm-mapping.json # creates developers/fixm-4.2.0-to-airm-1.0.0.html using developers/template.html html = open("data/html/templates/template.html").read() soup = BeautifulSoup(html, "lxml") f = open("data/html/export/developers/fixm-4.2.0-to-airm-1.0.0.html", "w+") f.write(soup.prettify()) f.close() # creates assets/js/mapping-table.js injecting the contents of assets/js/fixm-mapping.json as values and using assets/js/mapping-table-template.js with open(json_mapping_file) as json_file: with open( 'data/html/templates/mapping-table-template.js') as fin, open( 'data/html/export/assets/js/mapping-table.js', 'w') as fout: for line in fin: if ' var values = [] ;' in line: line = ' var values = ' + json_file.read() + ' ;\n' fout.write(line) # loads assets/js/fixm-mapping.json as a dictionary with open(json_mapping_file) as json_file: json_contents = json_file.read() mapping_list = json.loads(json_contents) # creates one page per concept in the mapping html = open("data/html/templates/concept-template.html").read() for trace in mapping_list: #print(trace['Concept']) components = str(trace['Id']).split(":") container_concept = components[1] #TO-DO replace shortnames in id with full namespaces full_id = str(trace['Id']) # creates developers/fixm-4.2.0-to-airm-1.0.0/CONCEPT NAME.html using developers/concept-template.html soup = BeautifulSoup(html, "lxml") # container concept for breadcrumb soup.find( text="CONTAINER CONCEPT HERE").replace_with(container_concept) # name for heading soup.find(text="CONTAINER@CONCEPT NAME HERE").replace_with( trace['Concept']) # ID for sub heading soup.find(text="FULL ID HERE").replace_with(full_id) # definition soup.find(text="DEFINITION HERE").replace_with(str( trace['Definition'])) # type soup.find(text="TYPE HERE").replace_with(str(trace['Type'])) # rationale soup.find(text="RATIONALE HERE").replace_with(str(trace['Rationale'])) # notes soup.find(text="NOTES HERE").replace_with(str(trace['Notes'])) # semantic correspondence name and url new_link = BeautifulSoup( '<a href="' + trace['url'] + '">' + trace['Correspondence'] + '</a>', "lxml") row = soup.find(text="AIRM CONCEPT HERE").parent row.clear() row.append(new_link.a) # AIRM concept definition entry = airm.load_and_find_urn(trace['urn']) soup.find(text="AIRM CONCEPT DEFINITION HERE").replace_with( entry["definition"]) # semantic correspondence url new_link = BeautifulSoup( '<a href="' + trace['addurl'] + '">' + trace['Additional'] + '</a>', "lxml") addrow = soup.find(text="AIRM ADDITIONAL CONCEPT HERE").parent addrow.clear() addrow.append(new_link.a) #page_content = BeautifulSoup("<div>"+container_concept+"</div>") #soup.find(text="CONTAINER CONCEPT HERE").replace_with(page_content) filename = trace['Concept'] filename = filename.replace("@", ".") f = open(mapping_pages_directory + "/" + filename + ".html", "w+") f.write(soup.prettify()) f.close() #DONE print(str(airm.not_found_counter) + " AIRM URNs were not found") print("Done")
def create_html_pages(): import amxm import airm amxm = amxm.Amxm() airm = airm.Airm() amxm_info_concepts_dict = amxm.get_information_concepts() for info_concept in amxm_info_concepts_dict: if info_concept['Information Concept']!="missing data": print(info_concept['Information Concept']) #creates soup for concept page using concept-template.html html = open("data/html/templates/AMXM-concept-template.html").read() soup = BeautifulSoup(html, "lxml") #span = soup.new_tag("span") #span.string = str(info_concept['Information Concept']) #soup.find(id="BC_INFO_CONCEPT_NAME").insert(0,span)span = soup.new_tag("span") #span.string = str(info_concept['Information Concept']) soup.title.string = str(info_concept['Information Concept'])+" - AMXM 2.0.0 to AIRM 1.0.0 | AIRM.aero" soup.find(text="FIXM_CLASS_NAME_BC").replace_with(str(info_concept['Information Concept'])) definition = str(info_concept["Concept Definition"]) definition = definition.replace("Definition: ","") soup.find(text="FIXM_CLASS_DEFINITION").replace_with(definition) h2 = soup.new_tag("h2") h2.string = str(info_concept['Information Concept']) soup.find(id="INFO_CONCEPT_NAME").insert(0,h2) code = soup.new_tag("code") datac_identifier = info_concept['Concept Identifier'] code.string = datac_identifier code["class"] = "text-secondary" soup.find(id="INFO_CONCEPT_NAME").insert(1,code) traces = amxm.get_traces_by_info_concept(info_concept['Information Concept']) for trace in traces: if trace['Data Concept'] != "missing data": print('\t'+trace['Data Concept']) tr = soup.new_tag("tr") if trace["Data Concept"] != "": td_dc_name = soup.new_tag("td") url = "#"+trace["Data Concept"] text = trace["Data Concept"] new_link = soup.new_tag("a") new_link['href'] = url new_link.string = text td_dc_name.insert(1,new_link) tr.insert(1,td_dc_name) if trace["Concept Definition"] != "": td_def = soup.new_tag("td") definition = str(trace["Concept Definition"]) definition = definition.replace("Definition: ","") td_def.string = definition tr.insert(2,td_def) soup.find(id="DATA_CONCEPTS_LIST").insert(1,tr) for trace in traces: if trace['Data Concept'] != "missing data": property_div = soup.new_tag("div") property_div["style"] = "border: 0.5px solid #b2b2b2;border-radius: 4px;box-shadow: 2px 2px #b2b2b2;padding: 15px;padding-bottom: 0px; margin-bottom: 30px" h3 = soup.new_tag("h3") h3.string = str(trace["Data Concept"]) h3["id"] = str(trace["Data Concept"]) h3["style"] = "padding-top: 120px; margin-top: -120px;" property_div.insert(0,h3) code = soup.new_tag("code") identifier = trace['Concept Identifier'] code.string = identifier code["class"] = "text-secondary" property_div.insert(1,code) p = soup.new_tag("p") definition = str(trace["Concept Definition"]) definition = definition.replace("Definition: ","") p.string = definition br = soup.new_tag("br") p.insert(2,br) property_div.insert(2,p) sc_h5 = soup.new_tag("h5") sc_h5.string = "Semantic Correspondence" sc_h5['style'] = "margin-top: 40px;" property_div.insert(3,sc_h5) sc_div = soup.new_tag("div") sc_div["class"] = "table-responsive" sc_table = soup.new_tag("table") sc_table["class"] = "table" sc_thead = soup.new_tag("thead") tr = soup.new_tag("tr") th = soup.new_tag("th") th.string = "AIRM Concept" tr.insert(1,th) th = soup.new_tag("th") th.string = "Definition" tr.insert(2,th) sc_thead.insert(1,tr) sc_table.insert(1,sc_thead) tbody = soup.new_tag("tbody") #for each insert row print('\t\tSemantic Corresponce:') if str(trace['AIRM Concept Identifier']) == "missing data": tr = soup.new_tag("tr") td = soup.new_tag("td") line = str(trace['Special Case']) url = create_url(line) text = create_name(line) a = soup.new_tag("a") a['href'] = url a['target'] = "_blank" a.string = text a["data-toggle"] = "tooltip" a["data-placement"] = "right" a["title"] = line td.insert(1,a) tr.insert(1,td) td = soup.new_tag("td") airm_entry = airm.load_and_find_urn(line) td.string = airm_entry["definition"] tr.insert(2,td) tbody.insert(1,tr) else: sem_correspondences = str(trace['AIRM Concept Identifier']).split('\n') for line in sem_correspondences: print('\t\t\t'+line) tr = soup.new_tag("tr") td = soup.new_tag("td") url = create_url(line) text = create_name(line) a = soup.new_tag("a") a['href'] = url a['target'] = "_blank" a.string = text a["data-toggle"] = "tooltip" a["data-placement"] = "right" a["title"] = line td.insert(1,a) tr.insert(1,td) td = soup.new_tag("td") airm_entry = airm.load_and_find_urn(line) td.string = airm_entry["definition"] tr.insert(2,td) tbody.insert(1,tr) sc_table.insert(2,tbody) sc_div.insert(1,sc_table) property_div.insert(4,sc_div) if str(trace["Rationale"]) != "missing data": h5 = soup.new_tag("h5") h5.string = "Rationale" property_div.insert(5,h5) p = soup.new_tag("p") p.string = str(trace["Rationale"]) print('Rationale:'+str(trace["Rationale"])) property_div.insert(6,p) if str(trace["Remarks"]) != "missing data": notes_h5 = soup.new_tag("h5") notes_h5.string = "Remarks" property_div.insert(7,notes_h5) p = soup.new_tag("p") p.string = str(trace["Remarks"]) print('Remarks:'+str(trace["Remarks"])) property_div.insert(8,p) top_link_p = soup.new_tag("p") new_link = soup.new_tag("a") new_link['href'] = "#top" new_icon = soup.new_tag("i") new_icon['class'] = "fa fa-arrow-circle-up" new_icon["data-toggle"] = "tooltip" new_icon["data-placement"] = "left" new_icon["title"] = "Top of page" new_link.insert(1,new_icon) top_link_p.insert(1,new_link) top_link_p['class'] = "text-right" property_div.insert(9,top_link_p) soup.find(id="DATA_CONCEPTS_DETAIL").insert(1,property_div) f= open("docs/developers/amxm-2.0.0-to-airm-1.0.0/"+str(info_concept['Information Concept'])+".html","w+") f.write(soup.prettify()) f.close()
def create_logical_model_item_page(record, template, scope, children, supplements=None): if record["stereotype"] != "missing data": print(record['class name']) from bs4 import BeautifulSoup soup = BeautifulSoup(template, "lxml") soup.title.string = str( record['class name']) + " - Logical Model | AIRM.aero" soup.find(text="FIXM_CLASS_NAME_BC").replace_with( str(record['class name'])) h2 = soup.new_tag("h2") h2.string = str(record['class name']) span_supplement = soup.new_tag("spam") if scope == "european-supplement/": span_supplement['class'] = "badge badge-secondary" span_supplement.string = "European Supplement" h2.insert(1, span_supplement) soup.find(id="INFO_CONCEPT_NAME").insert(0, h2) code = soup.new_tag("code") code.string = record['urn'] code["class"] = "text-secondary" soup.find(id="INFO_CONCEPT_NAME").insert(1, code) soup.find(text="FIXM_CLASS_DEFINITION").replace_with( str(record['definition'])) p = soup.new_tag("p") insert_index = 1 if record["source"] != "missing data": b = soup.new_tag("b") b.string = "Source: " p.insert(insert_index, b) insert_index = insert_index + 1 span = soup.new_tag("span") span.string = record["source"] p.insert(insert_index, span) insert_index = insert_index + 1 br = soup.new_tag("br") p.insert(insert_index, br) insert_index = insert_index + 1 if record["synonyms"] != "missing data": b = soup.new_tag("b") b.string = "Synonyms: " p.insert(insert_index, b) insert_index = insert_index + 1 span = soup.new_tag("span") span.string = record["synonyms"] p.insert(insert_index, span) insert_index = insert_index + 1 br = soup.new_tag("br") p.insert(insert_index, br) insert_index = insert_index + 1 if record["abbreviation"] != "missing data": b = soup.new_tag("b") b.string = "Abbreviations: " p.insert(insert_index, b) insert_index = insert_index + 1 span = soup.new_tag("span") span.string = record["abbreviation"] p.insert(insert_index, span) insert_index = insert_index + 1 br = soup.new_tag("br") p.insert(insert_index, br) insert_index = insert_index + 1 #insert parent if record["parent"] != "missing data": b = soup.new_tag("b") parent = str(record["parent"]) if scope == "european-supplement/": if "ses:eurocontrol" in record["parent urn"]: b.string = "Parent concept: : " else: b.string = "Supplements: " else: b.string = "Parent concept: " p.insert(insert_index, b) insert_index = insert_index + 1 url = create_url_for_supplements(str(record["parent"]), str(record["parent urn"]), scope) text = parent print("-parent: " + text) new_link = soup.new_tag("a") new_link['href'] = url new_link.string = text p.insert(insert_index, new_link) insert_index = insert_index + 1 br = soup.new_tag("br") p.insert(insert_index, br) insert_index = insert_index + 1 #insert children if children != None: b = soup.new_tag("b") b.string = "Children: " p.insert(insert_index, b) insert_index = insert_index + 1 for child in children: url = create_url_for_supplements(str(child["class name"]), str(record["urn"]), scope) text = str(child["class name"]) + "; " print("-child: " + text) new_link = soup.new_tag("a") new_link['href'] = url new_link.string = text p.insert(insert_index, new_link) insert_index = insert_index + 1 br = soup.new_tag("br") p.insert(insert_index, br) insert_index = insert_index + 1 #insert supplemented by if supplements != None: b = soup.new_tag("b") b.string = "Supplemented by: " p.insert(insert_index, b) insert_index = insert_index + 1 for entry in supplements: url = create_url_for_supplements(str(entry["class name"]), str(entry["urn"]), scope) text = str(entry["class name"]) + "; " print("-supplemented by: " + text) new_link = soup.new_tag("a") new_link['href'] = url new_link.string = text p.insert(insert_index, new_link) insert_index = insert_index + 1 br = soup.new_tag("br") p.insert(insert_index, br) insert_index = insert_index + 1 # Insert properties import airm airm = airm.Airm() results = airm.get_logical_properties_by_class( str(record['class name']), scope) if results != None: print("-scope: " + scope) hr = soup.new_tag("hr") p.insert(insert_index, hr) insert_index = insert_index + 1 b = soup.new_tag("b") b.string = "Properties: " p.insert(insert_index, b) insert_index = insert_index + 1 br = soup.new_tag("br") p.insert(insert_index, br) insert_index = insert_index + 1 for result in results: tr = soup.new_tag("tr") if result["property name"] != "": td_dc_name = soup.new_tag("td") url = "#" + str(result["property name"]) text = str(result["property name"]) new_link = soup.new_tag("a") new_link['href'] = url new_link.string = text td_dc_name.insert(1, new_link) tr.insert(1, td_dc_name) if result["definition"] != "": td_def = soup.new_tag("td") td_def.string = str(result["definition"]) tr.insert(2, td_def) if record["stereotype"] == "CodeList": td_dc_type = soup.new_tag("td") enump = soup.new_tag("p") enump.string = "enum value" td_dc_type.insert(1, enump) tr.insert(3, td_dc_type) elif str(result["type"]) in [ "Integer", "CharacterString", "Boolean", "Number", "Date", "DateTime", "TM_Duration", "GM_Curve", "GM_Point", "GM_Solid", "GM_Surface", "MD_Metadata", "Angle", "Decimal", "Real", "Bit", "LanguageCode", "ClockTime" ]: td_dc_type = soup.new_tag("td") enump = soup.new_tag("p") enump.string = str(result["type"]) td_dc_type.insert(1, enump) tr.insert(3, td_dc_type) elif result["type"] != "": td_dc_type = soup.new_tag("td") url = create_url_for_supplements(str(result['type']), str(result['type urn']), scope) text = str(result["type"]) new_link = soup.new_tag("a") new_link['href'] = url new_link.string = text td_dc_type.insert(1, new_link) tr.insert(3, td_dc_type) soup.find(id="DATA_CONCEPTS_LIST").insert(1, tr) for trace in results: print('\t+' + str(trace['property name'])) property_div = soup.new_tag("div") property_div[ "style"] = "border: 0.5px solid #b2b2b2;border-radius: 4px;box-shadow: 2px 2px #b2b2b2;padding: 15px;padding-bottom: 0px; margin-bottom: 30px" h3 = soup.new_tag("h3") h3.string = str(trace["property name"]) h3["id"] = str(trace["property name"]) h3["style"] = "padding-top: 120px; margin-top: -120px;" property_div.insert(0, h3) code = soup.new_tag("code") identifier = trace['urn'] code.string = identifier code["class"] = "text-secondary" property_div.insert(1, code) p2 = soup.new_tag("p") p2.string = str(trace["definition"]) br = soup.new_tag("br") p2.insert(2, br) property_div.insert(2, p2) if record["stereotype"] == "CodeList": p3 = soup.new_tag("p") p3.string = "type: enum value" property_div.insert(3, p3) elif str(trace["type"]) in [ "Integer", "CharacterString", "Boolean", "Number", "Date", "DateTime", "TM_Duration", "GM_Curve", "GM_Point", "GM_Solid", "GM_Surface", "MD_Metadata", "Angle", "Decimal", "Real", "Bit", "LanguageCode", "ClockTime" ]: td_dc_type = soup.new_tag("td") enump = soup.new_tag("p") enump.string = "type: " + str(trace["type"]) property_div.insert(3, enump) else: p3 = soup.new_tag("p") p3.string = "type: " span = soup.new_tag("span") url = create_url_for_supplements(str(trace['type']), trace['type urn'], scope) text = trace["type"] new_link = soup.new_tag("a") new_link['href'] = url new_link.string = text span.insert(1, new_link) p3.insert(2, span) property_div.insert(3, p3) connections = airm.get_connections_by_urn(trace['urn']) if connections != None: p4 = soup.new_tag("p") button = soup.new_tag("button") button["class"] = "btn btn-light" button["type"] = "button" button["data-toggle"] = "collapse" button["data-target"] = "#" + str( trace["property name"]) + "collapse" button["aria-expanded"] = "false" button["aria-controls"] = "collapseExample" button.string = "Show correspondences" p4.insert(1, button) property_div.insert(4, p4) sc_div = soup.new_tag("div") sc_div["class"] = "table-responsive collapse" sc_div["id"] = str(trace["property name"]) + "collapse" sc_table = soup.new_tag("table") sc_table["class"] = "table" sc_thead = soup.new_tag("thead") tr = soup.new_tag("tr") th = soup.new_tag("th") th.string = "Model" tr.insert(1, th) th = soup.new_tag("th") th.string = "Concept" tr.insert(2, th) sc_thead.insert(1, tr) sc_table.insert(1, sc_thead) tbody = soup.new_tag("tbody") for entry in connections: tr = soup.new_tag("tr") url_path = "" if scope == "european-supplement/": url_path = "../../../../developers/" else: url_path = "../../../developers/" if entry["concept_name"] != 'missing data': print('\t\t*' + str(entry["concept_target"])) td = soup.new_tag("td") text = entry["model_name"] pm = soup.new_tag("p") pm.string = text td.insert(1, pm) tr.insert(1, td) td = soup.new_tag("td") url = url_path + entry["model_path"] + "/" + entry[ "concept_target"] text = entry["concept_name"] a = soup.new_tag("a") a['href'] = url a['target'] = "_blank" a.string = text td.insert(1, a) tr.insert(2, td) tbody.insert(1, tr) sc_table.insert(2, tbody) sc_div.insert(1, sc_table) property_div.insert(5, sc_div) top_link_p = soup.new_tag("p") new_link = soup.new_tag("a") new_link['href'] = "#top" new_icon = soup.new_tag("i") new_icon['class'] = "fa fa-arrow-circle-up" new_icon["data-toggle"] = "tooltip" new_icon["data-placement"] = "left" new_icon["title"] = "Top of page" new_link.insert(1, new_icon) top_link_p.insert(1, new_link) top_link_p['class'] = "text-right" property_div.insert(6, top_link_p) soup.find(id="DATA_CONCEPTS_DETAIL").insert(1, property_div) soup.find(id="INFO_CONCEPT_OTHER").insert(insert_index, p) filename = classname_to_filename(str(record['class name'])) f = open("docs/airm/viewer/1.0.0/logical-model/" + scope + filename, "w+") f.write(soup.prettify()) f.close()
def create_conceptual_model_item_page(record, template, scope): if record["stereotype"] != "missing data": print(record['class name']) from bs4 import BeautifulSoup soup = BeautifulSoup(template, "lxml") soup.title.string = str( record['class name']) + " - Conceptual Model | AIRM.aero" soup.find(text="CONCEPT_NAME_BC").replace_with( str(record['class name'])) h2 = soup.new_tag("h2") h2.string = str(record['class name']) span_supplement = soup.new_tag("spam") if record["supplement"] == "\t\t\tEuropean Supplement": span_supplement['class'] = "badge badge-secondary" span_supplement.string = "European Supplement" h2.insert(1, span_supplement) soup.find(id="INFO_CONCEPT_NAME").insert(0, h2) code = soup.new_tag("code") code.string = record['urn'] code["class"] = "text-secondary" soup.find(id="INFO_CONCEPT_NAME").insert(1, code) soup.find(text="CONCEPT_DEFINITION").replace_with( str(record['definition'])) p = soup.new_tag("p") insert_index = 1 if record["source"] != "missing data": b = soup.new_tag("b") b.string = "Source: " p.insert(insert_index, b) insert_index = insert_index + 1 span = soup.new_tag("span") span.string = record["source"] p.insert(insert_index, span) insert_index = insert_index + 1 br = soup.new_tag("br") p.insert(insert_index, br) insert_index = insert_index + 1 if record["synonyms"] != "missing data": b = soup.new_tag("b") b.string = "Synonyms: " p.insert(insert_index, b) insert_index = insert_index + 1 span = soup.new_tag("span") span.string = record["synonyms"] p.insert(insert_index, span) insert_index = insert_index + 1 br = soup.new_tag("br") p.insert(insert_index, br) insert_index = insert_index + 1 if record["abbreviation"] != "missing data": b = soup.new_tag("b") b.string = "Abbreviations: " p.insert(insert_index, b) insert_index = insert_index + 1 span = soup.new_tag("span") span.string = str(record["abbreviation"]) p.insert(insert_index, span) insert_index = insert_index + 1 br = soup.new_tag("br") p.insert(insert_index, br) insert_index = insert_index + 1 # Insert related concepts import airm airm = airm.Airm() results = airm.get_concept_properties_by_parent( str(record['class name']), scope) if results != None: print("RESULTS for " + str(record['class name']) + "SCOPE: " + scope) print(results) hr = soup.new_tag("hr") p.insert(insert_index, hr) insert_index = insert_index + 1 b = soup.new_tag("b") b.string = "Related: " p.insert(insert_index, b) insert_index = insert_index + 1 br = soup.new_tag("br") p.insert(insert_index, br) insert_index = insert_index + 1 for result in results: print('\t' + result['property name']) span = soup.new_tag("span") span.string = result["property name"] p.insert(insert_index, span) insert_index = insert_index + 1 url = create_url_for_supplements(str(result['type']), result['type urn'], scope) text = result["type"] print(text) new_link = soup.new_tag("a") new_link['href'] = url new_link.string = text p.insert(insert_index, new_link) insert_index = insert_index + 1 br = soup.new_tag("br") p.insert(insert_index, br) insert_index = insert_index + 1 soup.find(id="DATA_CONCEPTS_DETAIL").insert(insert_index, p) filename = classname_to_filename(str(record['class name'])) f = open("docs/airm/viewer/1.0.0/conceptual-model/" + scope + filename, "w+") f.write(soup.prettify()) f.close()