<commit_before>from __future__ import unicode_literals

from datetime import datetime
import logging
import os
import platform
import shutil
import sqlite3

import reprozip
from reprozip import _pytracer
from reprozip.linux_pkgs import identify_packages, magic_dirs, system_dirs


def escape(s):
    return "'%s'" % s.replace('\\', '\\\\').replace("'", "\\'")


class File(object):
    """A file, used at some point during the experiment.
    """
    def __init__(self, path):
        self.path = path
        self.what = None
        stat = os.stat(path)
        if stat is not None:
            self.size = stat.st_size
        else:
            self.size = None

    #                               read
    #                              +------+
    #                              |      |
    #                read          v      +   write
    # (init) +------------------> ONLY_READ +-------> READ_THEN_WRITTEN
    #        |                                           ^         +
    #        |                                           |         |
    #        +-------> WRITTEN +--+                      +---------+
    #          write    ^         |                      read, write
    #                   |         |
    #                   +---------+
    #                   read, write
    READ_THEN_WRITTEN   = 0<commit_msg>Catches os.stat() raising OSError<commit_after>from __future__ import unicode_literals

from datetime import datetime
import logging
import os
import platform
import shutil
import sqlite3

import reprozip
from reprozip import _pytracer
from reprozip.linux_pkgs import identify_packages, magic_dirs, system_dirs


def escape(s):
    return "'%s'" % s.replace('\\', '\\\\').replace("'", "\\'")


class File(object):
    """A file, used at some point during the experiment.
    """
    def __init__(self, path):
        self.path = path
        self.what = None
        try:
            stat = os.stat(path)
        except OSError:
            self.size = None
        else:
            self.size = stat.st_size

    #                               read
    #                              +------+
    #                              |      |
    #                read          v      +   write
    # (init) +------------------> ONLY_READ +-------> READ_THEN_WRITTEN
    #        |                                           ^         +
    #        |                                           |         |
    #        +-------> WRITTEN +--+                      +---------+
    #          write    ^         |                      read, write
    #                   |         |
    #                   +---------+
    #                   read, write
    READ_THEN_WRITTEN   = 0
{'fraction_non_alphanumeric': 0.12886597938144329, 'fraction_numerical': 0.0014727540500736377, 'mean_word_length': 0.9013296011196641, 'pattern_counts': {'":': 0, '<': 3, '<?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': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4468130', 'n_tokens_mistral': 717, 'n_tokens_neox': 674, 'n_words': 162}