<commit_before># -*- coding: utf-8 -*-

import os, re
from snakemake.exceptions import MissingOutputException

__author__ = "<NAME>"

class IOFile(str):
	wildcard_regex = "\{(?P<name>\w+?)(,(?P<constraint>.*))?\}"
	_register = dict()
	
	@classmethod
	def create(cls, file, temp = False):
		obj = None
		if file in cls._register:
			obj = cls._register[file]
		else:
			obj = IOFile(file)
			cls._register[file] = obj 
		if obj._temp == None:
			obj._temp = temp
		return obj
	
	def __init__(self, file, protected = False):
		self._file = file
		self._needed = 0
		self._temp = None
		self._protected = protected
		
	def need(self):
		self._needed += 1
	
	def used(self):
		self._needed -= 1
		if self._temp:
			os.remove(self._file)

	def exists(self):<commit_msg>Fixed a bug where temp files are deleted too early.<commit_after># -*- coding: utf-8 -*-

import os, re
from snakemake.exceptions import MissingOutputException

__author__ = "<NAME>"

class IOFile(str):
	wildcard_regex = "\{(?P<name>\w+?)(,(?P<constraint>.*))?\}"
	_register = dict()
	
	@classmethod
	def create(cls, file, temp = False):
		obj = None
		if file in cls._register:
			obj = cls._register[file]
		else:
			obj = IOFile(file)
			cls._register[file] = obj 
		if obj._temp == None:
			obj._temp = temp
		return obj
	
	def __init__(self, file, protected = False):
		self._file = file
		self._needed = 0
		self._temp = None
		self._protected = protected
		
	def need(self):
		self._needed += 1
	
	def used(self):
		self._needed -= 1
		if self._temp and not self._needed:
			os.remove(self._file)

	def exists(self):
{'fraction_non_alphanumeric': 0.14492753623188406, 'fraction_numerical': 0.005040957781978576, 'mean_word_length': 3.37465564738292, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1328407', 'n_tokens_mistral': 632, 'n_tokens_neox': 552, 'n_words': 151}