-
Notifications
You must be signed in to change notification settings - Fork 0
/
milestones.py
224 lines (201 loc) · 7.4 KB
/
milestones.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
import argparse
import logging
import sys
from datetime import datetime
import milestones
from milestones.excel import load_f2due_pmcs_excel
from milestones.utility import get_pmcs_path_months
def parse_args():
default_wbs = "02C"
parser = argparse.ArgumentParser(description="Prepare DM milestone summaries.")
parser.add_argument(
"--pmcs-data",
help=f"Path to PMCS Excel extract; default={milestones.get_latest_pmcs_path()}",
default=milestones.get_latest_pmcs_path(),
)
parser.add_argument(
"--local-data",
help=f"Path to local annotations; default={milestones.get_local_data_path()}.",
default=milestones.get_local_data_path(),
)
parser.add_argument("--verbose", "-v", action="count", default=0)
subparsers = parser.add_subparsers(title="Output targets")
# Celeb uses fdue forecast date
celeb = subparsers.add_parser("celeb", help="Generate celebratory milestones.")
celeb.add_argument("--output", help="Filename for output", default="milestones.rst")
celeb.add_argument("--pmcs-comp", help="Filename for PMCS compare")
celeb.add_argument(
"--months",
help="Specify number of months prior to use for comparison",
type=int,
default=0,
)
celeb.add_argument(
"--table",
help="Generate table for milestones not bullet list",
action="store_true",
)
celeb.add_argument("--inc", help="Top or Y", default="Top")
celeb.set_defaults(func=milestones.celeb)
gantt = subparsers.add_parser("gantt", help="Generate Gantt chart.")
gantt.add_argument(
"--embedded",
help="Format for embedding in another document",
action="store_true",
)
gantt.add_argument("--output", help="Filename for output", default="gantt.tex")
gantt.set_defaults(func=milestones.gantt)
burndown = subparsers.add_parser(
"burndown", help="Generate milestone burndown chart."
)
filename, burndown_start, burndown_end = "burndown.png", "2016-10-30", "2025-03-03"
burndown.add_argument(
"--start-date",
type=datetime.fromisoformat,
default=burndown_start,
help=(
f"Start date for the burndown chart (YYYY-MM-DD); "
f"default={burndown_start}."
),
)
burndown.add_argument(
"--end-date",
type=datetime.fromisoformat,
default=burndown_end,
help=f"Start date for the burndown chart (YYYY-MM-DD); default={burndown_end}.",
)
burndown.add_argument(
"--output", help="Filename for output; default={filename}.", default=filename
)
burndown.set_defaults(func=milestones.burndown)
burndown.add_argument(
"--prefix",
help="List of prefixes for burndown milestones.",
default="DM- DLP- LDM-503-",
)
burndown.add_argument(
"--months",
help="Specify number of months prior to use as forecast",
type=int,
default=0,
)
csv = subparsers.add_parser(
"csv", help="Generate a CSV version of the milestone schedule."
)
filename = "milestones.csv"
csv.add_argument(
"--output", help=f"Filename for output; default={filename}.", default=filename
)
csv.set_defaults(func=milestones.csv)
jira = subparsers.add_parser("jira", help="Sync milestone details to Jira.")
jira.add_argument(
"--prompt", help="Prompt for username/password for jira.", action="store_true"
)
jira.set_defaults(func=milestones.cjira)
remaining = subparsers.add_parser(
"remaining", help="Print a list of remaining milestones."
)
as_of = datetime.now().isoformat()
remaining.add_argument(
"--wbs",
default=default_wbs,
help=f"Include only milestones for this WBS; default={default_wbs}",
)
remaining.set_defaults(func=milestones.remaining)
delayed = subparsers.add_parser(
"delayed", help="Print a list of delayed milestones."
)
as_of = datetime.now().isoformat()
delayed.add_argument(
"--wbs",
default=default_wbs,
help=f"Include only milestones for this WBS; default={default_wbs}",
)
delayed.add_argument(
"--as-of",
type=datetime.fromisoformat,
default=as_of,
help=f"Print incomplete milestones due by this date; default={as_of}",
)
delayed.set_defaults(func=milestones.delayed)
predecessors = subparsers.add_parser(
"predecessors", help="List each milestone with its predecessors"
)
predecessors.set_defaults(func=milestones.predecessors)
graph = subparsers.add_parser(
"graph", help="Generate Graphviz dot showing milestone relationships."
)
graph.add_argument("--output", help="Filename for output", default="graph.dot")
graph.add_argument(
"--wbs",
default=default_wbs,
help=f"Include only milestones for this WBS; default={default_wbs}",
)
graph.set_defaults(func=milestones.graph)
# RHL cartoon based on P6 "summary chart" and "celebratory milestone" entries
blockschedule = subparsers.add_parser(
"blockschedule", help="Generate the cartoon of the schedule."
)
blockschedule.add_argument(
"--output", help="Filename for output", default="blockschedule.pdf"
)
blockschedule.add_argument(
"--start-date", help="Starting date for cartoon (ISO 8601 format)"
)
blockschedule.add_argument(
"--end-date", help="Ending date for cartoon (ISO 8601 format)"
)
blockschedule.add_argument(
"--fontsize", help="Fontsize for activities", type=int, default=5
)
blockschedule.add_argument(
"--legend-location",
default=None,
help="Location for legend, overrides config file",
)
blockschedule.add_argument(
"--show-weeks", help="Show week boundaries", action="store_true", default=False
)
blockschedule.set_defaults(func=milestones.blockschedule)
# K. Reil report for schedule
report = subparsers.add_parser(
"report", help="Generate report with slipage of the schedule per milestone."
)
report.add_argument("--output", help="Filename for output", default="report.csv")
report.add_argument(
"--prefix",
help="List of prefixes for report milestones.",
default="SIT COM SUM",
)
report.add_argument(
"--months",
help="Specify number of months prior to use as 3rd date",
type=int,
default=2,
)
report.add_argument(
"--start-date",
type=datetime.fromisoformat,
default=burndown_start,
help=(
f"Start date for the miletones report (YYYY-MM-DD); "
f"default={burndown_start}."
),
)
report.set_defaults(func=milestones.report)
args = parser.parse_args()
log_levels = [logging.WARN, logging.INFO, logging.DEBUG, logging.NOTSET]
logging.basicConfig(level=log_levels[args.verbose])
if not hasattr(args, "func"):
parser.print_usage()
sys.exit(1)
return args
if __name__ == "__main__":
args = parse_args()
print("Working with " + args.pmcs_data)
load_tasks = args.func == milestones.blockschedule
milestones = milestones.load_milestones(args.pmcs_data, args.local_data, load_tasks)
if "months" in args and args.months > 0:
fpath = get_pmcs_path_months(args.pmcs_data, args.months)
load_f2due_pmcs_excel(fpath, milestones)
args.func(args, milestones)