<commit_before>import os
import sys
import time

from fleet.utility import *
from fleet.utility import LOG as L
from fleet.script import testcase

class TestCase(testcase.TestCase_Base):

    def initialize(self):
        if self.enable_timeout("home.png"):
            self.tap_timeout("action_formation.png"); time.sleep(2)
            self.tap_timeout("action_home.png")
            return self.enable_timeout("home.png")
        else:
            self.adb.stop("com.dmm.dmmlabo.kancolle/.AppEntry")
            time.sleep(5)
            self.adb.invoke("com.dmm.dmmlabo.kancolle/.AppEntry"); time.sleep(2)
            self.tap_timeout("start_music_off.png", timeout=2); time.sleep(2)
            self.tap_timeout("start_game.png", timeout=2); time.sleep(2)
            return self.enable_timeout("home.png")

    def supply(self, fleet):
        if not self.enable_timeout("home.png"):
            return False
        self.tap_timeout("action_supply.png"); time.sleep(2)
        if not self.enable_timeout(self.__supply_fleet_focus(fleet), loop=2, timeout=2):
            self.tap_timeout(self.__supply_fleet(fleet)); time.sleep(2)
        self.tap_timeout("supply_all.png"); time.sleep(2)
        return True

    def __supply_fleet(self, fleet):
        return "supply_fleet_%s.png" % fleet

    def __supply_fleet_focus(self, fleet):
        return "supply_fleet_%s_focus.png" % fleet

    def exercises(self):
        if not self.enable_timeout("home.png"):
            return False
        self.tap_timeout("action_sortie.png"); time.sleep(2)
        self.tap_timeout("sortie_exercises.png"); time.sleep(2)
        p = POINT(self.get("position.exercises_x"),
                  self.get("position.exercises_y"),
                  self.get("position.exercises_width"),
                  self.get("position.exercises_height"))
        for _ in range(5):
            if self.enable_pattern_crop("exercises_win_*.png", p, loop=3, timeout=1):
                L.info("I'm already fighting. I won.")
            elif self.enable_pattern_crop("exercises_lose_*.png", p, loop=3, timeout=1):
                L.info("I'm already fighting. I lost.")
            else:
                L.info(p);
                while not self.enable_timeout("exercises_start.png", loop=3, timeout=2):
                    self._tap(p); time.sleep(3)
                self.tap_timeout("exercises_start.png", loop=3, timeout=1); time.sleep(2)
                self.tap_timeout("exercises_attack.png", loop=3, timeout=1); time.sleep(2)
                while not self.enable_timeout("next.png", loop=3, timeout=2):
                    if self.tap_timeout("trail_formation.png", loop=3, timeout=1): time.sleep(2)
                    if self.tap_timeout("night_battle_start.png"): time.sleep(1)
                    time.sleep(10)
                while self.tap_timeout("next.png", loop=3, timeout=2): time.sleep(5)
                break
            p.x = int(p.x) - int(p.width); L.info("Point : %s" % str(p))
            if int(p.x) < 0:
                self.home(); return False
        return self.enable_timeout("home.png")

    def expedition(self, fleet, id):
        if not self.enable_timeout("home.png"):
            return False
        self.tap_timeout("action_sortie.png"); time.sleep(2)
        self.tap_timeout("sortie_expedition.png"); time.sleep(2)
        self.__expedition_stage(id); time.sleep(2)
        self.tap_timeout(self.__expedition_id(id)); time.sleep(2)
        if self.enable_timeout("expedition_done.png", loop=2, timeout=2):
            return False
        self.tap_timeout("expedition_decide.png"); time.sleep(2)
        if not self.enable_timeout(self.__expedition_fleet_focus(fleet), loop=2, timeout=2):
            self.tap_timeout(self.__expedition_fleet(fleet)); time.sleep(2)
        if self.enable_timeout("expedition_unable.png", loop=2, timeout=2):
            return False<commit_msg>update.<commit_after>import os
import sys
import time

from fleet.utility import *
from fleet.utility import LOG as L
from fleet.script import testcase

class TestCase(testcase.TestCase_Base):

    def initialize(self):
        if self.enable_timeout("home.png"):
            self.tap_timeout("action_formation.png"); time.sleep(2)
            self.tap_timeout("action_home.png")
            return self.enable_timeout("home.png")
        else:
            self.adb.stop("com.dmm.dmmlabo.kancolle/.AppEntry")
            time.sleep(5)
            self.adb.invoke("com.dmm.dmmlabo.kancolle/.AppEntry"); time.sleep(2)
            self.tap_timeout("start_music_off.png", timeout=2); time.sleep(2)
            self.tap_timeout("start_game.png", timeout=2); time.sleep(2)
            return self.enable_timeout("home.png")

    def supply(self, fleet):
        if not self.enable_timeout("home.png"):
            return False
        self.tap_timeout("action_supply.png"); time.sleep(2)
        if not self.enable_timeout(self.__supply_fleet_focus(fleet), loop=2, timeout=2):
            self.tap_timeout(self.__supply_fleet(fleet)); time.sleep(2)
        self.tap_timeout("supply_all.png"); time.sleep(2)
        return True

    def __supply_fleet(self, fleet):
        return "supply_fleet_%s.png" % fleet

    def __supply_fleet_focus(self, fleet):
        return "supply_fleet_%s_focus.png" % fleet

    def exercises(self):
        if not self.enable_timeout("home.png"):
            return False
        self.tap_timeout("action_sortie.png"); time.sleep(2)
        self.tap_timeout("sortie_exercises.png"); time.sleep(2)
        p = POINT(self.get("position.exercises_x"),
                  self.get("position.exercises_y"),
                  self.get("position.exercises_width"),
                  self.get("position.exercises_height"))
        for _ in range(5):
            if self.enable_pattern_crop("exercises_win_*.png", p, loop=3, timeout=1):
                L.info("I'm already fighting. I won.")
            elif self.enable_pattern_crop("exercises_lose_*.png", p, loop=3, timeout=1):
                L.info("I'm already fighting. I lost.")
            else:
                L.info(p);
                while not self.enable_timeout("exercises_start.png", loop=3, timeout=2):
                    self._tap(p); time.sleep(3)
                self.tap_timeout("exercises_start.png", loop=3, timeout=1); time.sleep(2)
                self.tap_timeout("exercises_attack.png", loop=3, timeout=1); time.sleep(2)
                while not self.enable_timeout("next.png", loop=3, timeout=2):
                    if self.tap_timeout("trail_formation.png", loop=3, timeout=1): time.sleep(2)
                    if self.tap_timeout("night_battle_start.png"): time.sleep(1)
                    time.sleep(10)
                while self.tap_timeout("next.png", loop=3, timeout=2): time.sleep(5)
                break
            p.x = int(p.x) - int(p.width); L.info("Point : %s" % str(p))
            if int(p.x) < 0:
                self.home(); return False
        return self.enable_timeout("home.png")

    def expedition(self, fleet, id):
        if not self.enable_timeout("home.png"):
            return False
        self.tap_timeout("action_sortie.png"); time.sleep(2)
        self.tap_timeout("sortie_expedition.png"); time.sleep(2)
        self.__expedition_stage(id); time.sleep(2)
        self.tap_timeout(self.__expedition_id(id)); time.sleep(2)
        if self.enable_timeout("expedition_done.png", loop=2, timeout=2):
            return False
        self.tap_timeout("expedition_decide.png"); time.sleep(2)
        if not self.enable_timeout(self.__expedition_fleet_focus(fleet), loop=2, timeout=2):
            self.tap_timeout(self.__expedition_fleet(fleet)); time.sleep(2)
        if self.enable_timeout("expedition_unable.png", loop=2, timeout=2):
            return True
{'fraction_non_alphanumeric': 0.13313647451534216, 'fraction_numerical': 0.013352163307228142, 'mean_word_length': 2.480786416443253, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1199878', 'n_tokens_mistral': 2583, 'n_tokens_neox': 2466, 'n_words': 407}