Beispiel #1
0
    def test_cb() -> None:
        heat = results.Heat(
            allow_inconsistent=not options.get_bool("inhibit_inconsistent"))
        #pylint: disable=protected-access
        heat._parse_do4("""432;1;1;All
Lane1;991.03;991.02;
Lane2;48.00;48.00;
Lane3;600.20;600.20;
Lane4;0;0;0
Lane5;312.34;312.34;
Lane6;678.12;679.12;
Lane7;1000.03;1000.03;
Lane8;1000.03;1000.03;
Lane9;1010.03;1010.03;
Lane10;1000.03;1000.03;
F679E29E3D8A4CC4""".split("\n"))
        # Names from https://www.name-generator.org.uk/
        #pylint: disable=protected-access
        heat._parse_scb("""#432 GIRLS 13&O 1650 FREE
MILLER, STEPHANIE   --TEAM1           
DAVIS, SARAH        --TEAM1           
GARCIA, ASHLEY      --TEAM1           
WILSON, JESSICA     --TEAM1           
                    --                
MOORE, SAMANTHA     --TEAM1           
JACKSON, AMBER      --TEAM1           
TAYLOR, MELISSA     --TEAM1           
ANDERSON, RACHEL    --TEAM1           
WHITE, MEGAN        --TEAM1           """.split("\n"))
        heat_cb(heat)
def test_parse_scb():
    """Ensure we can parse the scb format correctly"""
    lines = """#18 BOYS 10&U 50 FLY
                    --                
                    --                
                    --                
PERSON, JUST A      --TEAM            
                    --                
BIGBIGBIGLY, NAMENAM--LONGLONGLONGLONG
                    --                
                    --                
                    --                
                    --                
                    --                
                    --                
                    --                
XXXXXXX, YYYYYY Z   --                
                    --                
AAAAA, B            --X               
                    --                
                    --                
                    --                
                    --                """.split("\n")
    assert len(lines) == 21
    res = results.Heat(event="18", heat=1)
    res._parse_scb(lines)  # pylint: disable=protected-access
    assert res.event_desc == "BOYS 10&U 50 FLY"
    assert res.lanes[3].name == "PERSON, JUST A"
    assert res.lanes[3].team == "TEAM"
    assert res.lanes[5].name == "BIGBIGBIGLY, NAMENAM"
    assert res.lanes[5].team == "LONGLONGLONGLONG"
    assert not res.lanes[3].is_empty()
    assert res.lanes[4].is_empty()

    res = results.Heat(event="18", heat=2)
    res._parse_scb(lines)  # pylint: disable=protected-access
    assert res.event_desc == "BOYS 10&U 50 FLY"
    assert res.lanes[3].name == "XXXXXXX, YYYYYY Z"
    assert res.lanes[3].team == ""
    assert res.lanes[5].name == "AAAAA, B"
    assert res.lanes[5].team == "X"
Beispiel #3
0
 def _file_cb(self) -> None:
     allow = not self._config.get_bool("inhibit_inconsistent")
     self._result = results.Heat(allow_inconsistent = allow)
     filename = self._fc.get_selected_file()
     self._result.load_do4(filename)
     self._fi.meet.set(0)
     self._fi.race.set(0)
     # Example .....016-129-005A-0055.do4
     match = re.match(r"^.*[^\d](\d+)-[^-]+-[^-]+-(\d+)\.do4$", filename)
     if match:
         self._fi.meet.set(int(match.group(1)))
         self._fi.race.set(int(match.group(2)))
     finfo = os.stat(filename)
     modified = datetime.datetime.fromtimestamp(finfo.st_mtime, tz=datetime.timezone.utc)
     self._fi.date.set(modified.date().isoformat())
     self._fi.time.set(modified.time().strftime("%I:%M:%S %p"))
     self._fi.event.set(self._result.event_num)
     self._fi.heat.set(self._result.heat_num)
     self._spin_cb()
Beispiel #4
0
 def on_created(self, event):
     time.sleep(1)
     with sentry_sdk.start_transaction(op="new_result",
                                       name="New race result") as txn:
         inhibit = self._options.get_bool("inhibit_inconsistent")
         txn.set_tag("inhibit_inconsistent", inhibit)
         heat = results.Heat(allow_inconsistent=not inhibit)
         try:
             heat.load_do4(event.src_path)
             scb_filename = f"E{heat.event_num}.scb"
             heat.load_scb(
                 os.path.join(self._options.get_str("start_list_dir"),
                              scb_filename))
         except results.FileParseError:
             pass
         except FileNotFoundError:
             pass
         txn.set_tag("has_discription", heat.event_desc != "")
         txn.set_tag("lanes", self._options.get_int("num_lanes"))
         self._hcb(heat)
def test_parse_do4_empty_event():
    """Handle empty event #s that happen when event list is empty/exhausted"""
    lines = """;1;1;All
Lane1;;353.00;
Lane2;344.68;344.76;
Lane3;330.82;330.61;
Lane4;354.49;354.46;
Lane5;341.58;341.58;
Lane6;352.50;352.67;
Lane7;0;0;0
Lane8;0;0;0
Lane9;0;0;0
Lane10;0;0;0
FDDEBE8AA47C716C""".split("\n")

    res = results.Heat()
    res._parse_do4(lines)  # pylint: disable=protected-access
    assert res.event_num == ""
    assert res.heat_num == 1
    assert res.num_expected_times() == 2
    assert len(res.lanes[0].times) == 1
    assert len(res.lanes[1].times) == 2
    assert res.lanes[6].is_empty()
    assert not res.lanes[3].is_empty()
def test_parse_do4():
    """Ensure we can parse the do4 format correctly"""
    lines = """129;4;1;All
Lane1;0;0;0
Lane2;75.95;75.93;
Lane3;0;0;0
Lane4;73.33;73.32;
Lane5;0;0;0
Lane6;75.51;75.59;
Lane7;0;0;0
Lane8;0;0;0
Lane9;0;0;0
Lane10;0;0;0
F679E29E3D8A4CC4""".split("\n")

    res = results.Heat()
    res._parse_do4(lines)  # pylint: disable=protected-access
    assert res.event_num == "129"
    assert res.heat_num == 4
    assert res.num_expected_times() == 2
    assert len(res.lanes[0].times) == 0
    assert len(res.lanes[1].times) == 2
    assert res.lanes[0].is_empty()
    assert not res.lanes[3].is_empty()