JoanGiner commited on
Commit
d8117a8
·
1 Parent(s): 5c69731

markdown generated well. still panding loading state

Browse files
Files changed (2) hide show
  1. markdownGenerator.py +84 -64
  2. sdc_view.py +9 -10
markdownGenerator.py CHANGED
@@ -1,68 +1,88 @@
1
- def generate_markdown(session_state):
2
-
3
  html_str= f"""
4
- # The Software diversity card of {session_state["master_title"]}
5
- {session_state["master_desc"]}
6
- ## 🏢 Teams Summary
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
- <table>
9
- <tr>
10
- <th>Name</th>
11
- <th>Type</th>
12
- <th>Age Range</th>
13
- <th>Ethnicities</th>
14
- <th>Genders</th>
15
- <th>Team Size</th>
16
- <th>Average Tenure</th>
17
- <th>Start Date</th>
18
- <th>Location</th>
19
- </tr>
20
- <tr>
21
- <td><strong>DevelopmentTeam</strong></td>
22
- <td>DevelopmentTeam</td>
23
- <td>25-30</td>
24
- <td>Colombian, Brazilian, Argentinian, French, Spanish, Pakistani, Serbian, Iranian, Moroccan, Italian</td>
25
- <td>Male 80%, Female 20%</td>
26
- <td>15</td>
27
- <td>4.3</td>
28
- <td>11-08-2022</td>
29
- <td>Luxembourg</td>
30
- </tr>
31
- <tr>
32
- <td><strong>Usability Testers</strong></td>
33
- <td>Tester Team</td>
34
- <td>22-24</td>
35
- <td>French</td>
36
- <td>Non-disclosed</td>
37
- <td>18</td>
38
- <td>0.5</td>
39
- <td>17-10-2023</td>
40
- <td>University of Luxembourg</td>
41
- </tr>
42
- <tr>
43
- <td><strong>Computer Science Students</strong></td>
44
- <td>Target Community</td>
45
- <td>18-100</td>
46
- <td>Non-disclosed</td>
47
- <td>Non-disclosed</td>
48
- <td>-</td>
49
- <td>0</td>
50
- <td>-</td>
51
- <td>France & Luxembourg</td>
52
- </tr>
53
- <tr>
54
- <td><strong>Climate Public Servants</strong></td>
55
- <td>Target Community</td>
56
- <td>20-100</td>
57
- <td>Non-disclosed</td>
58
- <td>Non-disclosed</td>
59
- <td>-</td>
60
- <td>3-5</td>
61
- <td>-</td>
62
- <td>Luxembourg</td>
63
- </tr>
64
- </table>
65
 
66
- ---
67
- """
68
  return html_str
 
1
+ def generate_markdown(state):
2
+ print(state)
3
  html_str= f"""
4
+ # The Software diversity card of {state["master"]["title"]}
5
+ {state["master"]["desc"]}
6
+ ## 🏢 Teams Summary
7
+
8
+ <table>
9
+ <tr>
10
+ <th>Name</th>
11
+ <th>Description</th>
12
+ <th>Type</th>
13
+ <th>Age Range</th>
14
+ <th>Ethnicities</th>
15
+ <th>Genders</th>
16
+ <th>Team Size</th>
17
+ <th>Location</th>
18
+ </tr>"""
19
+ ## If development team addit
20
+ if 'participants' in state:
21
+ for key, participant in state['participants'].items():
22
+ if participant['name']:
23
+ html_str = html_str + f"""
24
+ <tr>
25
+ <td><strong>{participant['name']}</strong></td>
26
+ <td>{participant['description'].replace('\n', '')}</td>
27
+ """
28
+ if 'type' in body:
29
+ html_str = html_str + f"""<td>{body['type'][0]}</td>"""
30
+ else:
31
+ html_str = html_str + f"""<td> </td>"""
32
 
33
+ html_str = html_str + f"""
34
+ <td>{participant['age'][0]}-{participant['age'][1]}</td>
35
+ <td>{participant['ethnicities']}</td>
36
+ <td>{participant['genders']}</td>
37
+ <td>{participant['size']}</td>
38
+ <td>{participant['location']}</td>
39
+ </tr>"""
40
+ ## If target Communities add it
41
+ if state['socialContext']['targetCommunity']['name']:
42
+ html_str = html_str + f"""
43
+ <tr>
44
+ <td><strong>{state['socialContext']['targetCommunity']['name']}</strong></td>
45
+ <td>{state['socialContext']['targetCommunity']['description'].replace('\n', '')}</td>
46
+ <td> Targeted Community </td>
47
+ <td>{state['socialContext']['targetCommunity']['age'][0]}-{state['socialContext']['targetCommunity']['age'][1]}</td>
48
+ <td>{state['socialContext']['targetCommunity']['ethnicities']}</td>
49
+ <td>{state['socialContext']['targetCommunity']['genders']}</td>
50
+ <td> many </td>
51
+ <td>{state['socialContext']['targetCommunity']['location']}</td>
52
+ </tr>"""
53
+ ## If bodies add
54
+ if 'governance' in state:
55
+ if 'bodies' in state['governance']:
56
+ for key, body in state['governance']["bodies"].items():
57
+ if body['name']:
58
+ html_str = html_str + f"""
59
+ <tr>
60
+ <td><strong>{body['name'].replace('\n', '')}</strong></td>
61
+ <td>{body['description'].replace('\n', '')}</td>"""
62
+ if 'type' in body:
63
+ html_str = html_str + f"""<td>{body['type'][0]}</td>"""
64
+ else:
65
+ html_str = html_str + f"""<td> </td>"""
66
+ if body['organization']['name']:
67
+ html_str = html_str + f"""
68
+ <td>{body['organization']['age'][0]}-{body['organization']['age'][1]}</td>
69
+ <td>{body['organization']['ethnicities']}</td>
70
+ <td>{body['organization']['genders']}</td>
71
+ <td> - </td>
72
+ <td>{body['organization']['location']}</td>
73
+ </tr>"""
74
+
75
+ if body['participant']['name']:
76
+ html_str = html_str + f"""
77
+ <td>45</td>
78
+ <td>{body['participant']['ethincity']}</td>
79
+ <td>{body['participant']['gender']}</td>
80
+ <td> - </td>
81
+ <td>{body['participant']['location']}</td>
82
+ </tr>"""
83
+
84
+ ## End summary
85
+ html_str = html_str + f" </table>"
 
 
 
 
86
 
87
+
 
88
  return html_str
sdc_view.py CHANGED
@@ -41,9 +41,9 @@ def render_sdc():
41
  st.error(f"Error saving state: {e}")
42
 
43
  # Run this only once on first load.
44
- if "loaded" not in st.session_state:
45
- load_state()
46
- st.session_state["loaded"] = True
47
 
48
 
49
  # Example of how to filter and serialize session state
@@ -315,8 +315,8 @@ def render_sdc():
315
  Welcome to the Software Diversity Card Generator—a form-based application designed to empower you to highlight and promote diversity in software projects. Our innovative tool helps you generate comprehensive diversity cards in both JSON and Markdown formats, offering a transparent overview of the varied teams involved in development and governance, the user groups engaged in testing, and the tailored software adaptations for different social groups. By providing a structured model, an extended JSON syntax, and a toolkit backed by real-world examples, our platform aims to foster inclusive practices that can be embraced by open-source communities, academic journals, and forward-thinking businesses alike.
316
  """)
317
 
318
-
319
-
320
  ##
321
  ## Master info
322
  ##
@@ -443,17 +443,18 @@ def render_sdc():
443
  st.divider()
444
  st.subheader("The generated card")
445
  markDownTab, jsonTab = st.tabs(["**Compiled card in markdown**", "**Generated JSON**" ])
 
446
  with markDownTab:
447
 
448
  # Provide a download button
449
  st.download_button(
450
  label="Download Markdown",
451
- data=generate_markdown(st.session_state),
452
  file_name="SoftareDiveristyCard.md",
453
  mime="text/markdown"
454
  )
455
  st.text("Preview:")
456
- st.markdown(generate_markdown(st.session_state), unsafe_allow_html=True)
457
  with jsonTab:
458
 
459
  # Convert the session state to a JSON string
@@ -465,8 +466,6 @@ def render_sdc():
465
  mime="application/json"
466
  )
467
  # Display the session state as pretty JSON
468
- #st.json(serialize_session_state())
469
- final = unflatten(st.session_state["form_data"])
470
  st.text("Preview:")
471
- st.json(final)
472
 
 
41
  st.error(f"Error saving state: {e}")
42
 
43
  # Run this only once on first load.
44
+ #if "loaded" not in st.session_state:
45
+ # load_state()
46
+ # st.session_state["loaded"] = True
47
 
48
 
49
  # Example of how to filter and serialize session state
 
315
  Welcome to the Software Diversity Card Generator—a form-based application designed to empower you to highlight and promote diversity in software projects. Our innovative tool helps you generate comprehensive diversity cards in both JSON and Markdown formats, offering a transparent overview of the varied teams involved in development and governance, the user groups engaged in testing, and the tailored software adaptations for different social groups. By providing a structured model, an extended JSON syntax, and a toolkit backed by real-world examples, our platform aims to foster inclusive practices that can be embraced by open-source communities, academic journals, and forward-thinking businesses alike.
316
  """)
317
 
318
+ if st.button("Load the Besser's Software Diversity Card example", type="secondary"):
319
+ load_state()
320
  ##
321
  ## Master info
322
  ##
 
443
  st.divider()
444
  st.subheader("The generated card")
445
  markDownTab, jsonTab = st.tabs(["**Compiled card in markdown**", "**Generated JSON**" ])
446
+ unflattenedJson = unflatten(st.session_state["form_data"])
447
  with markDownTab:
448
 
449
  # Provide a download button
450
  st.download_button(
451
  label="Download Markdown",
452
+ data=generate_markdown(unflattenedJson),
453
  file_name="SoftareDiveristyCard.md",
454
  mime="text/markdown"
455
  )
456
  st.text("Preview:")
457
+ st.markdown(generate_markdown(unflattenedJson), unsafe_allow_html=True)
458
  with jsonTab:
459
 
460
  # Convert the session state to a JSON string
 
466
  mime="application/json"
467
  )
468
  # Display the session state as pretty JSON
 
 
469
  st.text("Preview:")
470
+ st.json(unflattenedJson)
471