# Path: will/utils.py
# def sizeof_fmt(num, suffix='B'):
#     # http://stackoverflow.com/a/1094933
#     for unit in ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi']:
#         if abs(num) < 1024.0:
#             return "%3.1f%s%s" % (num, unit, suffix)
#         num /= 1024.0
#     return "%.1f%s%s" % (num, 'Yi', suffix)
# 
# Path: will/backends/storage/base.py
# class BaseStorageBackend(PrivateBaseStorageBackend):
#     """
#     The base storage backend.  All storage backends must supply the following methods:
#     __init__() - sets up the connection
#     do_save() - saves a single value to a key
#     do_load() - gets a value from the backend
#     clear() - deletes a key
#     clear_all_keys() - clears the db
#     """
# 
#     def do_save(self, key, value, expire=None):
#         raise NotImplementedError
# 
#     def do_load(self, key):
#         raise NotImplementedError
# 
#     def clear(self, key):
#         raise NotImplementedError
# 
#     def clear_all_keys(self):
#         raise NotImplementedError


import logging
import os
import time
from will.utils import sizeof_fmt
from .base import BaseStorageBackend
        elif os.path.exists(expire_path):
            os.unlink(expire_path)

    def clear(self, key):
        key_path, expire_path = self._key_paths(key)
        if os.path.exists(key_path):
            os.unlink(key_path)
        if os.path.exists(expire_path):
            os.unlink(expire_path)

    def clear_all_keys(self):
        for filename in self._all_setting_files():
            os.unlink(filename)

    def do_load(self, key):
        key_path, expire_path = self._key_paths(key)

        if os.path.exists(expire_path):
            with open(expire_path, 'r') as f:
                expire_at = f.read()
            if time.time() > int(expire_at):
                # the current value has expired
                self.clear(key)
                return

        if os.path.exists(key_path):
            with open(key_path, 'r') as f:
                return f.read()

    def size(self):

# Path: will/utils.py
# def sizeof_fmt(num, suffix='B'):
#     # http://stackoverflow.com/a/1094933
#     for unit in ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi']:
#         if abs(num) < 1024.0:
#             return "%3.1f%s%s" % (num, unit, suffix)
#         num /= 1024.0
#     return "%.1f%s%s" % (num, 'Yi', suffix)
# 
# Path: will/backends/storage/base.py
# class BaseStorageBackend(PrivateBaseStorageBackend):
#     """
#     The base storage backend.  All storage backends must supply the following methods:
#     __init__() - sets up the connection
#     do_save() - saves a single value to a key
#     do_load() - gets a value from the backend
#     clear() - deletes a key
#     clear_all_keys() - clears the db
#     """
# 
#     def do_save(self, key, value, expire=None):
#         raise NotImplementedError
# 
#     def do_load(self, key):
#         raise NotImplementedError
# 
#     def clear(self, key):
#         raise NotImplementedError
# 
#     def clear_all_keys(self):
#         raise NotImplementedError


# Path: will/backends/storage/file_backend.py
import logging
import os
import time
from will.utils import sizeof_fmt
from .base import BaseStorageBackend

        elif os.path.exists(expire_path):
            os.unlink(expire_path)

    def clear(self, key):
        key_path, expire_path = self._key_paths(key)
        if os.path.exists(key_path):
            os.unlink(key_path)
        if os.path.exists(expire_path):
            os.unlink(expire_path)

    def clear_all_keys(self):
        for filename in self._all_setting_files():
            os.unlink(filename)

    def do_load(self, key):
        key_path, expire_path = self._key_paths(key)

        if os.path.exists(expire_path):
            with open(expire_path, 'r') as f:
                expire_at = f.read()
            if time.time() > int(expire_at):
                # the current value has expired
                self.clear(key)
                return

        if os.path.exists(key_path):
            with open(key_path, 'r') as f:
                return f.read()

    def size(self):

        return sizeof_fmt(sum([