-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogramdocx.py
More file actions
53 lines (40 loc) · 1.55 KB
/
programdocx.py
File metadata and controls
53 lines (40 loc) · 1.55 KB
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 11 08:49:33 2023
@author: repa
"""
# requires python-docx
from docx import Document
class WriteDocx:
def __init__(self, project):
self.pr = project
def authorList(self, fname):
doc = Document()
authors = self.pr.author_list
t = doc.add_table(len(authors), 2, style="Table Grid")
for i, au in enumerate(authors):
t.cell(i, 0).text = au.nameLastFirst()
t.cell(i, 1).text = ', '.join(au.getEventCodes())
doc.save(fname)
def eventList(self, fname):
doc = Document()
for day in self.pr.getDays():
doc.add_heading(day.printDate(), 2)
for event in day.events:
t = doc.add_table(2, 3, style="Table Grid")
t.cell(0, 0).text = \
f'{event.printDay()} {event.printStart()} - {event.printEnd()}'
t.cell(1, 0).text = event.venue
t.cell(1, 1).text = event.printEventCode()
t.cell(0, 1).text = event.printTitle()
t.cell(1, 2).text = event.printChair()
t.cell(0, 1).merge(t.cell(0,2))
if event.hasSession():
for item in event._session._items:
r = t.add_row()
r.cells[0].merge(r.cells[2])
r.cells[0].add_paragraph(item.title)
r.cells[0].add_paragraph(item.printAuthors())
doc.add_paragraph('')
doc.save(fname)