<commit_before>"""
Filesystem Storage object.
"""
import os, tempfile
from .base import BaseStorage, StorageError
from django.conf import settings


################################
#  Filesystem Storage Object
################################

class Storage(BaseStorage):
    """ Filesystem API Storage. """
    BACKUP_DIRECTORY = getattr(settings, 'DBBACKUP_FILESYSTEM_DIRECTORY', None)
    BACKUP_DIRECTORY = '/%s/' % BACKUP_DIRECTORY.strip('/')

    def __init__(self, server_name=None):
        self._check_filesystem_errors()
        self.name = 'Filesystem'
        BaseStorage.__init__(self)

    def _check_filesystem_errors(self):
        """ Check we have all the required settings defined. """
        if not self.BACKUP_DIRECTORY:
            raise StorageError('Filesystem storage requires DBBACKUP_FILESYSTEM_DIRECTORY to be defined in settings.')

    ###################################
    #  DBBackup Storage Methods
    ###################################

    def backup_dir(self):
        return self.BACKUP_DIRECTORY

    def delete_file(self, filepath):
        """ Delete the specified filepath. """
        os.unlink(filepath)

    def list_directory(self):
        """ List all stored backups for the specified. """
        filepaths = os.listdir(self.BACKUP_DIRECTORY)
        filepaths = [os.path.join(self.BACKUP_DIRECTORY, path) for path in filepaths]
        return sorted(filter(os.path.isfile, filepaths))
<commit_msg>Issue #20 - Backup to local disk fails in python 2.7.1 on Windows XP<commit_after>"""
Filesystem Storage object.
"""
import os
from .base import BaseStorage, StorageError
from django.conf import settings


################################
#  Filesystem Storage Object
################################

class Storage(BaseStorage):
    """ Filesystem API Storage. """
    BACKUP_DIRECTORY = getattr(settings, 'DBBACKUP_FILESYSTEM_DIRECTORY', None)

    def __init__(self, server_name=None):
        self._check_filesystem_errors()
        self.name = 'Filesystem'
        BaseStorage.__init__(self)

    def _check_filesystem_errors(self):
        """ Check we have all the required settings defined. """
        if not self.BACKUP_DIRECTORY:
            raise StorageError('Filesystem storage requires DBBACKUP_FILESYSTEM_DIRECTORY to be defined in settings.')

    ###################################
    #  DBBackup Storage Methods
    ###################################

    def backup_dir(self):
        return self.BACKUP_DIRECTORY

    def delete_file(self, filepath):
        """ Delete the specified filepath. """
        os.unlink(filepath)

    def list_directory(self):
        """ List all stored backups for the specified. """
        filepaths = os.listdir(self.BACKUP_DIRECTORY)
        filepaths = [os.path.join(self.BACKUP_DIRECTORY, path) for path in filepaths]
        return sorted(filter(os.path.isfile, filepaths))

{'fraction_non_alphanumeric': 0.17722395292488752, 'fraction_numerical': 0.0017307026652821046, 'mean_word_length': 3.6991869918699187, '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': '2123407', 'n_tokens_mistral': 785, 'n_tokens_neox': 758, 'n_words': 202}