<commit_before>from constants import *
import os
import stat
import urllib
import subprocess
import logging

logger = logging.getLogger(APP_NAME)

class Object:
    def __init__(self, path):
        self.name = os.path.basename(path)
        self.path = path
        self.syntax = None
        self.readable = False

        if os.path.isdir(self.path):
            self.type = DIR_MIME_TYPE
            self.size = None
            self.time = None
        else:
            try:
                file_stat = os.stat(self.path)
                self.size = file_stat.st_size
                self.time = file_stat.st_mtime
                self.readable = bool(file_stat.st_mode & stat.S_IROTH)
            except OSError:
                self.size = None
                self.time = None
            self.type = None

    def get_mime_type(self):
        if not self.type:
            try:
                # TODO Follow symlinks
                self.type = subprocess.check_output(['file',
                    '--mime-type', '--brief', self.path]).strip()
            except subprocess.CalledProcessError, error:
                logger.debug('File mime-type call failed. %r' % {
                    'return_code': error.returncode,
                    'output': error.output,
                })
        return self.type

    def get_syntax(self):
        if self.type == DIR_MIME_TYPE:
            return<commit_msg>Use in for object time<commit_after>from constants import *
import os
import stat
import urllib
import subprocess
import logging

logger = logging.getLogger(APP_NAME)

class Object:
    def __init__(self, path):
        self.name = os.path.basename(path)
        self.path = path
        self.syntax = None
        self.readable = False

        if os.path.isdir(self.path):
            self.type = DIR_MIME_TYPE
            self.size = None
            self.time = None
        else:
            try:
                file_stat = os.stat(self.path)
                self.size = file_stat.st_size
                self.time = int(file_stat.st_mtime)
                self.readable = bool(file_stat.st_mode & stat.S_IROTH)
            except OSError:
                self.size = None
                self.time = None
            self.type = None

    def get_mime_type(self):
        if not self.type:
            try:
                # TODO Follow symlinks
                self.type = subprocess.check_output(['file',
                    '--mime-type', '--brief', self.path]).strip()
            except subprocess.CalledProcessError, error:
                logger.debug('File mime-type call failed. %r' % {
                    'return_code': error.returncode,
                    'output': error.output,
                })
        return self.type

    def get_syntax(self):
        if self.type == DIR_MIME_TYPE:
            return
{'fraction_non_alphanumeric': 0.09078114004222379, 'fraction_numerical': 0.0, 'mean_word_length': 1.4786399302528335, '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': '2800696', 'n_tokens_mistral': 828, 'n_tokens_neox': 783, 'n_words': 181}