-
Notifications
You must be signed in to change notification settings - Fork 1
/
earthquakeReport.py
38 lines (28 loc) · 1.39 KB
/
earthquakeReport.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
from docx import Document
from docx.shared import Inches
class EarthquakeReport:
def __init__(self, workingPath):
self.workingPath = workingPath
self.document = Document()
def set_title(self, city, ruptureTime):
self.document.add_heading("Earthquake Report for " + city + " on " + ruptureTime[:ruptureTime.find("_")], 0)
def add_hazard_description(self, initialSummary, tectonicSummary):
self.document.add_heading("Hazard Description", 1)
self.document.add_paragraph(initialSummary)
self.document.add_paragraph(tectonicSummary)
self.document.add_picture(self.workingPath + "/overviewData/intensity.jpg", width=Inches(4.9), height=Inches(4.9))
def add_sections(self, sectionsDictionary):
for x in range(0, len(sectionsDictionary)):
key = list(sectionsDictionary.items())[x][0]
self.document.add_heading(key, 1)
self.document.add_paragraph(sectionsDictionary[key])
def add_picture(self, imagePath, width, height):
self.document.add_picture(imagePath, width=Inches(width), height=Inches(height))
def save(self):
self.document.add_page_break()
self.document.save(self.workingPath + "/briefing.docx")
class EarthquakeReportImage:
def __init__(self, imagePath, width, height):
self.imagePath = imagePath
self.width = width
self.height = height