<commit_before>#!/usr/bin/env python

import sys
import os
import re
import shutil
import subprocess
import argparse
import json

# Images comparison
from PIL import Image, ImageChops
import math
import operator

class cd:
  """Context manager for changing the current working directory"""
  def __init__(self, newPath):
    self.newPath = newPath

  def __enter__(self):
    self.savedPath = os.getcwd()
    os.chdir(self.newPath)

  def __exit__(self, etype, value, traceback):
    os.chdir(self.savedPath)


class bcolors:
  OKGREEN = '\033[92m'
  OKBLUE = '\033[94m'
  FAIL = '\033[91m'
  WARNING = '\033[93m'
  ENDC = '\033[0m'

  def disable(self):
    self.OKGREEN = ''
    self.OKBLUE = ''
    self.WARNING = ''
    self.FAIL = ''
    self.ENDC = ''


def success(message):
  print bcolors.OKGREEN + message + bcolors.ENDC

def info(message):
  print "[INFO] " + message

def error(message):
  print bcolors.FAIL + message + bcolors.ENDC

def debug(message):
  if verbose:
    print message

def warn(message):
  print bcolors.WARNING + message + bcolors.ENDC


def croak_and_slam_the_door(message):
  error(message)
  error("Exiting with status 1 (no hard feelings).")
  sys.exit(1)


def sanitize_test_cases():
  with cd('test_cases'):
    tests = os.listdir('.')

    errors = {}
    dirs = []

    for test in tests:
      if test == '.tmp':
        continue

      if sanitize_test_case(test):
        dirs.append(os.path.abspath(test))
      else:
        croak_and_slam_the_door("Invalid test case.")

    return dirs


def sanitize_test_case(test):
  if not has_desc(test):
    warn("[WARN] " + test + " does not contain 'desc' file.")
<commit_msg>Ignore invisible folders in visual tests<commit_after>#!/usr/bin/env python

import sys
import os
import re
import shutil
import subprocess
import argparse
import json

# Images comparison
from PIL import Image, ImageChops
import math
import operator

class cd:
  """Context manager for changing the current working directory"""
  def __init__(self, newPath):
    self.newPath = newPath

  def __enter__(self):
    self.savedPath = os.getcwd()
    os.chdir(self.newPath)

  def __exit__(self, etype, value, traceback):
    os.chdir(self.savedPath)


class bcolors:
  OKGREEN = '\033[92m'
  OKBLUE = '\033[94m'
  FAIL = '\033[91m'
  WARNING = '\033[93m'
  ENDC = '\033[0m'

  def disable(self):
    self.OKGREEN = ''
    self.OKBLUE = ''
    self.WARNING = ''
    self.FAIL = ''
    self.ENDC = ''


def success(message):
  print bcolors.OKGREEN + message + bcolors.ENDC

def info(message):
  print "[INFO] " + message

def error(message):
  print bcolors.FAIL + message + bcolors.ENDC

def debug(message):
  if verbose:
    print "[DBUG] " + message

def warn(message):
  print bcolors.WARNING + message + bcolors.ENDC


def croak_and_slam_the_door(message):
  error(message)
  error("Exiting with status 1 (no hard feelings).")
  sys.exit(1)


def sanitize_test_cases():
  with cd('test_cases'):
    tests = os.listdir('.')

    errors = {}
    dirs = []

    for test in tests:
      if test.startswith('.'):
        debug("Ignoring invisible folder '" + test + "'.")
        continue

      if sanitize_test_case(test):
        dirs.append(os.path.abspath(test))
      else:
        croak_and_slam_the_door("Invalid test case.")

    return dirs


def sanitize_test_case(test):
  if not has_desc(test):
    warn("[WARN] " + test + " does not contain 'desc' file.")

{'fraction_non_alphanumeric': 0.12441724941724942, 'fraction_numerical': 0.015151515151515152, 'mean_word_length': 3.254027261462206, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1653161', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1172, 'n_words': 307}