-
Notifications
You must be signed in to change notification settings - Fork 0
/
Puml_Tools.py
60 lines (50 loc) · 1.65 KB
/
Puml_Tools.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
import datetime
import Milestone
from plantweb.render import render_file
def get_date_range(milestones: list[Milestone.Milestone]):
mindate = None
maxdate = None
for milestone in milestones:
milestone_start_date = datetime.datetime.strptime(milestone._target_start, "%Y-%m-%d")
milestone_end_date = datetime.datetime.strptime(milestone._target_end, "%Y-%m-%d")
if (mindate is None):
mindate = milestone_start_date
maxdate = milestone_end_date
else:
if (milestone_start_date < mindate):
mindate = milestone_start_date
elif (milestone_end_date > maxdate):
maxdate = milestone_end_date
return [mindate, maxdate]
def get_all_teams(milestones):
teams = []
for milestone in milestones:
if milestone.team not in teams:
teams.append(milestone.label)
return teams
def sort_by_team(milestones):
milestones_by_team = {}
for milestone in milestones:
if milestone.team in milestones_by_team:
milestones_by_team[milestone.team].append(milestone)
else:
milestones_by_team[milestone.team] = [milestone]
return milestones_by_team
def render_puml_file(puml_string):
infile = 'milestones.png'
with open(infile, 'wb') as fd:
fd.write(puml_string.encode('utf-8'))
print('==> INPUT FILE:')
print(infile)
outfile = render_file(
infile,
renderopts={
'engine': 'graphviz',
'format': 'png'
},
cacheopts={
'use_cache': False
}
)
print('==> OUTPUT FILE:')
print(outfile)