from __future__ import absolute_import
import traceback
import os, errno
from .signal import interrupt_protect

class FileSystemAdapter(object):

    def __init__(self, path, **kwargs):
        self.directory = unicode(os.path.abspath(path))
        self.make_sure_path_exists(self.directory)

    def make_sure_path_exists(self, key):
        try:
            os.makedirs(key)
        except OSError as exception:
            if exception.errno != errno.EEXIST:
                raise

    def key_path(self, key):
        key = unicode(key)
        if key[0] == u'/':
            key = key[1:]
        return os.path.join(self.directory, unicode(key))

    def get(self, key):
        full_path = self.key_path(key)
        try:
            with open(full_path,'r') as f:
                return f.read()
        except IOError as e:
            if e.errno == errno.ENOENT:
                raise KeyError('{}: {}'.format(key,str(e)))

    @interrupt_protect
    def put(self, key, data):
        full_path = self.key_path(key)
        directory = os.path.dirname(full_path)
        self.make_sure_path_exists(directory)
        with open(full_path,'w') as f:
            f.write(data)

    def delete(self, key):
        full_path = self.key_path(key)
        try:
            os.remove(full_path)
        except OSError:
            # doesn't exist
            pass

    def exists(self, key):
        full_path = self.key_path(key)
        if os.path.isfile(full_path): 
            try:
                with open(full_path,'r') as f:
                    return True
            except IOError:
                return False
        else:
            return False

    def list(self, key='/'):
        full_path = self.key_path(key)
        for directory, subdirs, files in os.walk(full_path):
            for file in files:
                path = os.path.join(directory, file)
                # remove our directory
                path = path.split(self.directory)[1]
                yield path

@@ -204,24 +204,16 @@
 ctory = 
-unicode(
 os.path.
@@ -225,17 +225,16 @@
 th(path)
-)
 %0A       
@@ -513,28 +513,19 @@
   key = 
-unicode(
 key
-)
 %0A       
@@ -538,17 +538,16 @@
 y%5B0%5D == 
-u
 '/':%0A   
@@ -617,21 +617,12 @@
 ry, 
-unicode(
 key)
-)
 %0A%0A  
@@ -898,16 +898,34 @@
 str(e)))
+%0A            raise
 %0A%0A    @i

Remove unicoding of filenames.