Example #1
0
def load_arenas(fname):
    "Load arenas from a YAML file"

    y = yaml_loader.load(fname)

    arenas = []
    for name in y["arenas"]:
        arenas.append(name)

    return arenas
Example #2
0
def load_corners(fname):
    "Load corner colours from a YAML file"

    y = yaml_loader.load(fname)

    corners = {}
    for n, colour in y["corner_colours"].iteritems():
        c = Corner(n, colour)
        corners[n] = c

    return corners
Example #3
0
def load_teams(fname):
    "Load teams from a YAML file"

    y = yaml_loader.load(fname)

    teams = {}
    for tla, info in y["teams"].iteritems():
        tla = tla.upper()
        teams[tla] = Team(tla,info["name"])

    return teams
Example #4
0
def make_matches_today(root):
    schedule_path = os.path.join(root, "schedule.yaml")
    s = yaml_loader.load(schedule_path)
    first = s['match_periods']['league'][0]
    now = datetime.datetime.now(tzlocal())
    first['start_time'] = now - datetime.timedelta(minutes=1)
    end = now + datetime.timedelta(days=1)
    first['end_time'] = end
    del first['max_end_time']

    with open(schedule_path, 'w') as f:
        f.write(yaml.dump(s))
Example #5
0
    def create(cls, config_fname, scores, arenas):
        y = yaml_loader.load(config_fname)

        schedule = cls(y)

        k = KnockoutScheduler(schedule, scores, arenas, y)
        k.add_knockouts()

        schedule.knockout_rounds = k.knockout_rounds
        schedule.match_periods.append(k.period)

        return schedule
Example #6
0
    def _load_resfile(self, fname):
        y = yaml_loader.load(fname)

        match_id = (y["arena_id"], y["match_number"])
        if match_id in self.game_points:
            raise DuplicateScoresheet(match_id)

        game_points = self._scorer(y["teams"]).calculate_scores()
        self.game_points[match_id] = game_points

        # Build the disqualification dict
        dsq = []
        for tla, scoreinfo in y["teams"].iteritems():
            # disqualifications and non-presence are effectively the same
            # in terms of league points awarding.
            if scoreinfo.get("disqualified", False) or \
                not scoreinfo.get("present", True):
                dsq.append(tla)

        self.ranked_points[match_id] = ranker.get_ranked_points(game_points, dsq)
Example #7
0
			sys.exit()
		elif o in ("-t", "--type"):
			outtype = a
		elif o in ("-w", "--width"):
			width = int(a)
		else:
			assert False, "unknow option"
	
	if (len(args) < 1): 
		usage()
		sys.exit(2)

	basename = args[0]

	input = file(basename + '.yaml', 'r')	
	seqs = yaml_loader.load(input)
	if ( not seqs ):
		print >> sys.stderr, "Nothing to draw"
		sys.exit(1)
	
	collect_comps();
	if (outtype == "html"):
		mscout = file(basename + '.msc', 'w')	
		htmlout = file(basename + '.html', 'w')	
		gen_msc(mscout)
		gen_html(htmlout)
	elif (outtype == "text"):
		gen_ascii(width)

def usage():
	usage = """Usage:
Example #8
0
			file_name = a
		elif o in ("-e", "--exist"):
			verify_exist = True
			update_ignore_alarm_list(a)
			target_alarm = a
			alarm = compose_alarm(target_alarm)
		else:
			assert("no such option")

	if (len(args) >=2 ):
		path = args[1]
	expect = "*" 
	if (len(args) >=3 ):
		expect = args[2]

	seqs = yaml_loader.load(sys.stdin)

	if (verify_exist) :
		if (is_empty(seqs) or (not is_existing(seqs,alarm))) : 
			report_result(False,"No HIGH message with \"%s\" detected!" % target_alarm)
		else :
			print ("High messaage \"%s\" detected!" % target_alarm)
	else :
		if (is_empty(seqs)) : 
			report_result(True,"No HIGH message detected!" )
				

	new_seqs = filter_high(seqs)

	if (is_empty(new_seqs)):
		report_result(True,"No interested HIGH message %s detected!" % HIGH_ABSTRACT_GROUP)