Example #1
0
def top35_run_p_reports(master: Master, **kwargs) -> None:
    group = get_group(master, str(master.current_quarter), kwargs)
    for p in group:
        p_name = master.project_information[p]["Abbreviations"]
        print("Compiling summary for " + p_name)
        report_doc = open_word_doc(top35_root_path / "input/summary_temp.docx")
        output = compile_p_report(report_doc, master, p, **kwargs)
        output.save(top35_root_path /
                    "output/{}_report.docx".format(p_name))  # add quarter here
Example #2
0
def test_cal_group_including_removing(master):
    op_args = {"baseline": "standard", "remove": ["Mars"]}
    group = get_group(master, "Q1 20/21", **op_args)
    assert group == [
        "Sea of Tranquility",
        "Apollo 11",
        "Apollo 13",
        "Falcon 9",
        "Columbia",
    ]
Example #3
0
    def get_cs_milestones(self) -> None:
        """
        Creates project milestone dictionaries for current, last_quarter, and
        baselines when provided with group and baseline type.
        """
        sp_dict = {}
        self.iter_list = get_iter_list(self.kwargs, self.master)
        for tp in self.iter_list:  # tp time period
            self.kwargs["tp"] = tp
            lower_dict = {}
            raw_list = []
            self.group = get_group(self.master, tp, self.kwargs)
            for project_name in self.group:
                project_list = []
                p_data = get_correct_p_data(self.kwargs, self.master,
                                            self.baseline_type, project_name,
                                            tp)
                if p_data is None:
                    continue
                # i loops below removes None Milestone names and rejects non-datetime date values.
                p = self.master.abbreviations[project_name]["abb"]
                report = "Top 250"
                category = "Central Resource"
                for i in range(1, 17):
                    # these keys not present in all monthly masters.
                    try:
                        cs_response = p_data["R" + str(i) +
                                             " Central Response"]
                    except KeyError:
                        cs_response = None
                    try:
                        poc = p_data["R" + str(i) + " Point of Contact"]
                    except KeyError:
                        poc = None
                    # this not present in new entries
                    try:
                        secured = p_data["R" + str(i) + " secured"]
                    except KeyError:
                        secured = None

                    t = [
                        ("Project", p),
                        ("Requirement", p_data["R" + str(i) + " name"]),
                        # ("Type", "Approval"),
                        ("Escalated", p_data["R" + str(i) + " escalated to"]),
                        ("Date",
                         convert_date(p_data["R" + str(i) + " needed by"])),
                        ("Type", p_data["R" + str(i) + " type"]),
                        ("Central Response", cs_response),
                        ("PoC", poc),
                        ("Secured", secured),
                        ("Report", report),
                        ("Cat", category),
                    ]
                    milestone_info_handling(project_list, t, **self.kwargs)

                # loop to stop keys names being the same. Done at project level.
                # not particularly concise code.
                upper_counter_list = []
                for entry in project_list:
                    upper_counter_list.append(entry[1][1])
                upper_count = Counter(upper_counter_list)
                lower_counter_list = []
                for entry in project_list:
                    if upper_count[entry[1][1]] > 1:
                        lower_counter_list.append(entry[1][1])
                        lower_count = Counter(lower_counter_list)
                        new_require_key = (entry[1][1] + " (" +
                                           str(lower_count[entry[1][1]]) + ")")
                        entry[1] = ("Requirement", new_require_key)
                        raw_list.append(entry)
                    else:
                        raw_list.append(entry)

            # puts the list in chronological order
            sorted_list = sorted(raw_list,
                                 key=lambda k: (k[3][1] is None, k[3][1]))

            for r in range(len(sorted_list)):
                lower_dict["Requirement " + str(r)] = dict(sorted_list[r])

            sp_dict[tp] = lower_dict
        self.cs_dict = sp_dict