Example #1
0
    def get_part_vote_outcome(self, part):
        # returns the vote outcome of a party. the criteria of a perticular outcome is that 51% or more of the total number of party ledamöter must support the outcome
        part = part.lower()
        ant_mandat_dict = constants.ant_mandat(self.get_riksmote())
        ant_mandat_part = ant_mandat_dict[part]
        if ant_mandat_part == 0:
            return None
        part_vote_ja = self.get_part_vote_abs(part, "ja")
        part_vote_nej = self.get_part_vote_abs(part, "nej")
        part_vote_franv = self.get_part_vote_abs(part, "frånvarande")
        part_vote_avst = self.get_part_vote_abs(part, "avstår")
        
        if self.check_vote_crit(part_vote_ja, ant_mandat_part):
            part_vote_outcome = "ja"
        elif self.check_vote_crit(part_vote_nej, ant_mandat_part):
            part_vote_outcome = "nej"
        elif self.check_vote_crit(part_vote_franv, ant_mandat_part):
            part_vote_outcome = "frånvarande"
        elif self.check_vote_crit(part_vote_avst, ant_mandat_part):
            part_vote_outcome = "avstår"
        else:
            # if none of the voteing outcomes got support over the threshold (i.e. 51%) the outcome is inconclusive
            part_vote_outcome = "inconclusive"

        return part_vote_outcome
 def get_vote_franvaro_dict(self):
     vote_part_list = self.get_vote_part_list()
     vote_franvaro_dict = {}
     these_partier = self.get_these_parts()
     
     for vote_part in vote_part_list:
         for part in these_partier:
             try:
                 absence_percent = vote_part.get_part_vote_abs(part, "frånvarande")/constants.ant_mandat(vote_part.get_riksmote())[part.lower()]
                 vote_franvaro_dict[part].append(absence_percent)
             except KeyError:
                 # creates a list with attendence percent values for each vote_part
                 vote_franvaro_dict[part] = [absence_percent]
     # find the mean of each list of attendence percentages in the dict
     vote_franvaro_dict = {k: sum(v)/len(v) for k,v in vote_franvaro_dict.items()}
     
     return vote_franvaro_dict