<commit_before>__author__ = '<NAME>'

import os, shutil, errno
import random
import time
import threading
import io
import shutil
import tempfile

if os.name == 'nt':
    import ctypes
    kdll = ctypes.windll.LoadLibrary("kernel32.dll")

def which(program):
    def is_exe(fpath):
        if os.name=='nt':
            return os.path.isfile(fpath) or os.path.isfile(fpath+".exe") or os.path.isfile(fpath+".bat")
        else:
            return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

    fpath, fname = os.path.split(program)
    if fpath:
        program=os.path.realpath(program)
        if is_exe(program):
            return program
    else:
        path = shutil.which(program)
        if path:
            return os.path.realpath(path)

    return None

def copytree(src, dst, symlinks=False, hardlinks=False, ignore=None):
    names = os.listdir(src)
    if ignore is not None:
        ignored_names = ignore(src, names)
    else:
        ignored_names = set()

    mkdirs(dst)

    errors = []
    for name in names:
        if name in ignored_names:
            continue
        srcname = os.path.join(src, name)
        dstname = os.path.join(dst, name)
        try:
            if symlinks and os.path.islink(srcname):
                linkto = os.readlink(srcname)
                os.symlink(linkto, dstname)
            elif os.path.isdir(srcname):
                copytree(srcname, dstname, symlinks, hardlinks, ignore)
            elif hardlinks:
                os.link(srcname, dstname)
            else:
                shutil.copy2(srcname, dstname)
            # XXX What about devices, sockets etc.?
        except (IOError, os.error) as why:
            errors.append((srcname, dstname, str(why)))
        # catch the Error from the recursive copytree so that we can
        # continue with other files
        except shutil.Error as err:
            errors.extend(err.args[0])

    if errors:
        raise shutil.Error(errors)

def mkdirs(path):
    try:
        os.makedirs(path)
    except OSError as exc:
        if exc.errno == errno.EEXIST and os.path.isdir(path):
            pass
        else:
            raise

def touch(path, timevalue=None):
    if timevalue==None:
        timevalue=time.time()
    basedir = os.path.dirname(path)
    if not os.path.exists(basedir):
        os.makedirs(basedir)
    if not os.path.exists(path):
        with open(path, 'a'):
            os.utime(path, (timevalue, timevalue))
    else:
        (f, tmppath) = tempfile.mkstemp()
        os.utime(tmppath, (timevalue, timevalue))
        try:
            shutil.copystat(tmppath, path)
        except:
            os.remove(tmppath)
            raise Exception("Unable to set timestamp for %s." % path)
        os.remove(tmppath)

def file_is_older_than(path, seconds):<commit_msg>Reimplement touch() again (previous attempt didn't solved the owner problem).<commit_after>__author__ = '<NAME>'

import os, shutil, errno
import random
import time
import threading
import io
import shutil
import tempfile

if os.name == 'nt':
    import ctypes
    kdll = ctypes.windll.LoadLibrary("kernel32.dll")

def which(program):
    def is_exe(fpath):
        if os.name=='nt':
            return os.path.isfile(fpath) or os.path.isfile(fpath+".exe") or os.path.isfile(fpath+".bat")
        else:
            return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

    fpath, fname = os.path.split(program)
    if fpath:
        program=os.path.realpath(program)
        if is_exe(program):
            return program
    else:
        path = shutil.which(program)
        if path:
            return os.path.realpath(path)

    return None

def copytree(src, dst, symlinks=False, hardlinks=False, ignore=None):
    names = os.listdir(src)
    if ignore is not None:
        ignored_names = ignore(src, names)
    else:
        ignored_names = set()

    mkdirs(dst)

    errors = []
    for name in names:
        if name in ignored_names:
            continue
        srcname = os.path.join(src, name)
        dstname = os.path.join(dst, name)
        try:
            if symlinks and os.path.islink(srcname):
                linkto = os.readlink(srcname)
                os.symlink(linkto, dstname)
            elif os.path.isdir(srcname):
                copytree(srcname, dstname, symlinks, hardlinks, ignore)
            elif hardlinks:
                os.link(srcname, dstname)
            else:
                shutil.copy2(srcname, dstname)
            # XXX What about devices, sockets etc.?
        except (IOError, os.error) as why:
            errors.append((srcname, dstname, str(why)))
        # catch the Error from the recursive copytree so that we can
        # continue with other files
        except shutil.Error as err:
            errors.extend(err.args[0])

    if errors:
        raise shutil.Error(errors)

def mkdirs(path):
    try:
        os.makedirs(path)
    except OSError as exc:
        if exc.errno == errno.EEXIST and os.path.isdir(path):
            pass
        else:
            raise

def touch(path, timevalue=None):
    if timevalue==None:
        timevalue=time.time()
    basedir = os.path.dirname(path)
    if not os.path.exists(basedir):
        os.makedirs(basedir)
    try:
        with open(path, 'a'):
            os.utime(path, (timevalue, timevalue))
    except:
        (f, tmppath) = tempfile.mkstemp()
        try:
            shutil.copy2(path, tmppath)
            os.utime(tmppath, (timevalue, timevalue))
            os.remove(path)
            shutil.copy2(tmppath, path)
        except:
            os.remove(tmppath)
            raise Exception("Unable to set timestamp for %s." % path)
        os.remove(tmppath)

def file_is_older_than(path, seconds):
{'fraction_non_alphanumeric': 0.10576755532322704, 'fraction_numerical': 0.0017424638438752395, 'mean_word_length': 2.0564430244941425, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6095260', 'n_tokens_mistral': 1845, 'n_tokens_neox': 1814, 'n_words': 449}