<commit_before># Imports
import StringIO # For writing out the log to the "run_logs" folder
import time     # For getting the current timestamp
import os       # For working with files on the operating system
import platform # For determining what operating system the script is being run on
import zipfile  # For compressing the log files of past runs
import pygame   # This is the main graphics library used for the item tracker
import re       # For parsing the log file (regular expressions)
import json     # For importing the items and options
import urllib2  # For checking for updates to the item tracker
import string   # Used in generating a run summary
#import pygame._view # Uncomment this if you are trying to run release.py and you get: "ImportError: No module named _view"

# Import item tracker specific code
from view_controls.view import DrawingTool, Option
from game_objects.floor import Floor, Curse
from game_objects.item  import Item, Stat, ItemProperty

# Additional pygame imports
if platform.system() == "Windows":
    import pygameWindowInfo
from pygame.locals import *

# The main class of the program
class IsaacTracker:
    def __init__(self, verbose=False, debug=False, read_delay=1):
        # Class variables
        self.verbose          = verbose
        self.debug            = debug
        self.text_height      = 0
        self.text_margin_size = None  # Will be changed in load_options
        self.font             = None  # Will be changed in load_options
        self.seek             = 0
        self.framecount       = 0
        self.read_delay       = read_delay
        self.run_ended        = True
        self.log_not_found    = False
        self.content          = ""  # Cached contents of log
        self.splitfile        = []  # Log split into lines
        self.drawing_tool     = None
        self.file_prefix      = "../"

        # Initialize isaac stuff
        self.collected_items         = [] # List of items collected this run
        self.collected_item_info     = [] # List of "immutable" ItemInfo objects used for determining the layout to draw
        self.guppy_set               = set() # Used to keep track of whether we're guppy or not
        self.num_displayed_items     = 0
        self.selected_item_idx       = None
        self.seed                    = ""
        self.current_room            = ""
        self.blind_floor             = False
        self.getting_start_items     = False
        self.run_start_line          = 0
        self.run_start_frame         = 0
        self.bosses                  = []
        self.last_run                = {}
        self._image_library          = {}
        self.in_summary_list         = []
        self.summary_condition_list  = []
        self.items_info              = {}
        self.floors                  = []
        self.player_stats            = {}
        self.player_stats_display    = {}
        self.reset_player_stats()
        self.item_message_start_time = 0
        self.item_pickup_time        = 0
        self.item_position_index     = []
        self.current_floor           = None
        self.floor_tuple             = () # Tuple with first value being floor number, second value being alt stage value (0 or 1, r.n.)
        self.spawned_coop_baby       = 0  # The last spawn of a co-op baby
        self.roll_icon               = None
        self.blind_icon              = None

        self.GAME_VERSION = "" # I KNOW THIS IS WRONG BUT I DON'T KNOW WHAT ELSE TO DO

        # Load items info
        with open(self.file_prefix + "items.json", "r") as items_file:
            self.items_info = json.load(items_file)

    def save_options(self):
        with open(self.file_prefix + "options.json", "w") as json_file:
            json.dump(self.options, json_file, indent=3, sort_keys=True)

    # This is just for debugging
    def log_msg(self, msg, level):
        if level == "V" and self.verbose: print msg
        if level == "D" and self.debug:   print msg

    # This is just for the suffix of the boss kill number
    def suffix(self, d):
        return 'th' if 11 <= d <= 13 else {1: 'st', 2: 'nd', 3: 'rd'}.get(d % 10, 'th')

    def check_end_run(self, line, cur_line_num):
        if not self.run_ended:
            died_to  = ""
            end_type = ""
            if self.bosses and self.bosses[-1][0] in ['???', 'The Lamb', 'Mega Satan']:
                end_type = "Won"
            elif (self.seed != '') and line.startswith('RNG Start Seed:'):
                end_type = "Reset"
            elif line.startswith('Game Over.'):
                end_type = "Death"
                died_to = re.search('(?i)Killed by \((.*)\) spawned', line).group(1)
            if end_type:
                self.last_run = {
                    "bosses":   self.bosses,
                    "items":    self.collected_items,
                    "seed":     self.seed,
                    "died_to":  died_to,
                    "end_type": end_type
                }
                self.run_ended = True
                self.log_msg("End of Run! %s" % self.last_run, "D")
                if end_type != "Reset":
                    self.save_file(self.run_start_line, cur_line_num, self.seed)

    def save_file(self, start, end, seed):
        self.mkdir("run_logs")
        timestamp = int(time.time())<commit_msg>missed adding .. in front of the path to "run_logs" in one place<commit_after># Imports
import StringIO # For writing out the log to the "run_logs" folder
import time     # For getting the current timestamp
import os       # For working with files on the operating system
import platform # For determining what operating system the script is being run on
import zipfile  # For compressing the log files of past runs
import pygame   # This is the main graphics library used for the item tracker
import re       # For parsing the log file (regular expressions)
import json     # For importing the items and options
import urllib2  # For checking for updates to the item tracker
import string   # Used in generating a run summary
#import pygame._view # Uncomment this if you are trying to run release.py and you get: "ImportError: No module named _view"

# Import item tracker specific code
from view_controls.view import DrawingTool, Option
from game_objects.floor import Floor, Curse
from game_objects.item  import Item, Stat, ItemProperty

# Additional pygame imports
if platform.system() == "Windows":
    import pygameWindowInfo
from pygame.locals import *

# The main class of the program
class IsaacTracker:
    def __init__(self, verbose=False, debug=False, read_delay=1):
        # Class variables
        self.verbose          = verbose
        self.debug            = debug
        self.text_height      = 0
        self.text_margin_size = None  # Will be changed in load_options
        self.font             = None  # Will be changed in load_options
        self.seek             = 0
        self.framecount       = 0
        self.read_delay       = read_delay
        self.run_ended        = True
        self.log_not_found    = False
        self.content          = ""  # Cached contents of log
        self.splitfile        = []  # Log split into lines
        self.drawing_tool     = None
        self.file_prefix      = "../"

        # Initialize isaac stuff
        self.collected_items         = [] # List of items collected this run
        self.collected_item_info     = [] # List of "immutable" ItemInfo objects used for determining the layout to draw
        self.guppy_set               = set() # Used to keep track of whether we're guppy or not
        self.num_displayed_items     = 0
        self.selected_item_idx       = None
        self.seed                    = ""
        self.current_room            = ""
        self.blind_floor             = False
        self.getting_start_items     = False
        self.run_start_line          = 0
        self.run_start_frame         = 0
        self.bosses                  = []
        self.last_run                = {}
        self._image_library          = {}
        self.in_summary_list         = []
        self.summary_condition_list  = []
        self.items_info              = {}
        self.floors                  = []
        self.player_stats            = {}
        self.player_stats_display    = {}
        self.reset_player_stats()
        self.item_message_start_time = 0
        self.item_pickup_time        = 0
        self.item_position_index     = []
        self.current_floor           = None
        self.floor_tuple             = () # Tuple with first value being floor number, second value being alt stage value (0 or 1, r.n.)
        self.spawned_coop_baby       = 0  # The last spawn of a co-op baby
        self.roll_icon               = None
        self.blind_icon              = None

        self.GAME_VERSION = "" # I KNOW THIS IS WRONG BUT I DON'T KNOW WHAT ELSE TO DO

        # Load items info
        with open(self.file_prefix + "items.json", "r") as items_file:
            self.items_info = json.load(items_file)

    def save_options(self):
        with open(self.file_prefix + "options.json", "w") as json_file:
            json.dump(self.options, json_file, indent=3, sort_keys=True)

    # This is just for debugging
    def log_msg(self, msg, level):
        if level == "V" and self.verbose: print msg
        if level == "D" and self.debug:   print msg

    # This is just for the suffix of the boss kill number
    def suffix(self, d):
        return 'th' if 11 <= d <= 13 else {1: 'st', 2: 'nd', 3: 'rd'}.get(d % 10, 'th')

    def check_end_run(self, line, cur_line_num):
        if not self.run_ended:
            died_to  = ""
            end_type = ""
            if self.bosses and self.bosses[-1][0] in ['???', 'The Lamb', 'Mega Satan']:
                end_type = "Won"
            elif (self.seed != '') and line.startswith('RNG Start Seed:'):
                end_type = "Reset"
            elif line.startswith('Game Over.'):
                end_type = "Death"
                died_to = re.search('(?i)Killed by \((.*)\) spawned', line).group(1)
            if end_type:
                self.last_run = {
                    "bosses":   self.bosses,
                    "items":    self.collected_items,
                    "seed":     self.seed,
                    "died_to":  died_to,
                    "end_type": end_type
                }
                self.run_ended = True
                self.log_msg("End of Run! %s" % self.last_run, "D")
                if end_type != "Reset":
                    self.save_file(self.run_start_line, cur_line_num, self.seed)

    def save_file(self, start, end, seed):
        self.mkdir(self.file_prefix + "run_logs")
        timestamp = int(time.time())
{'fraction_non_alphanumeric': 0.08478341355053684, 'fraction_numerical': 0.004813032210292484, 'mean_word_length': 1.7891068662880742, 'pattern_counts': {'":': 14, '<': 7, '<?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': '4077520', 'n_tokens_mistral': 3125, 'n_tokens_neox': 2980, 'n_words': 949}