-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterp_page_generator.py
69 lines (51 loc) · 3.03 KB
/
interp_page_generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import dominate
from dominate.tags import *
import os
def get_interpretation_pages(project_interpretation_folder_path: str) -> list:
"""
Find all the interpretation pages in the given folder path. Interpretation pages are HTML files that are generaeted by CATMA.
:param project_interpretation_folder_path: The path to the folder that contains all the interpretation pages for a project.
"""
pages = []
for file in os.listdir(project_interpretation_folder_path):
if file.endswith('.html'):
pages.append(file)
return pages
def generate_overview_page_for_project(output_folder_path, project_name: str, project_interpretation_folder_path: str, project_interpretation_pages: list):
doc = dominate.document(title=f'Visualization of Non-Conformances and Overview of interpretations generated for {project_name}')
with doc.head:
link(rel='stylesheet', href='css/overview_page_stylesheet.css')
with doc:
h1(f'Non-conformance visualization for {project_name}')
with div(id='ncf_visualization'):
visualize_ncf_path = project_interpretation_folder_path.split('interpretations')[0] + 'visualization/'
with div(id='arch_model_viz'):
img(src=f'{visualize_ncf_path}plantuml.png')
h1(f'Overview of interpretations generated for {project_name}')
with div(id='interpretations_list'):
for page in project_interpretation_pages:
splitted = page.split('_')
if 'dynamic' in page:
ncf_type = 'dynamic'
else:
ncf_type = 'static'
involved_services = splitted[0] + ' and ' + splitted[1]
capitalized_type = ncf_type.capitalize()
h3(f'{capitalized_type} non-conformance between {involved_services}:')
a('Click here to view the interpretation for the ' + ncf_type + ' non-conformance between ' + involved_services , href=f'{project_interpretation_folder_path}/{page}')
with open(f'{output_folder_path}/{project_name}_overview.html', 'w') as f:
f.write(doc.render())
def main():
"""
This script is mainly used to generate a seperate HTML pages to list the interpretation of each project. As GitHub pages does not
allow us to get a directory view of subfolders, we would have to manually create this view ourselves.
"""
examples_folder_path = 'interpretation_examples'
projects = ['ewolff_microservice', 'shabbirdwd53_springboot-microservice', 'spring-petclinic_spring-petclinic-microservices', 'sqshq_piggymetrics']
project_to_interp_pages_mapping = dict()
for project in projects:
project_to_interp_pages_mapping[project] = get_interpretation_pages(f'{examples_folder_path}/{project}/interpretations/')
for project in project_to_interp_pages_mapping:
generate_overview_page_for_project('./', project, f'{examples_folder_path}/{project}/interpretations', project_to_interp_pages_mapping[project])
if __name__ == '__main__':
main()