# Path: historisation/historisation/storage.py
# class Storage(object):
#     # returns a string with the content of the file or None if it does not exist.
#     def get(self, path):
#         pass
# 
#     # returns true if the file exists
#     def exists(self, path):
#         pass
# 
#     # saves a file-like object at the given location
#     def save(self, path, file):
#         pass
# 
#     # returns a list of directories from the root
#     def get_dirs(self):
#         pass
# 
#     # returns the files from a given directory
#     def get_files(self, path):
#         pass
# 
#     # creates a new directory
#     def mkdir(self, path):
#         pass
# 
#     # moves
#     def move(self, source, dest):
#         pass
# 
#     # join
#     def join(self, *paths):
#         pass


import os
import errno
import logging
import shutil
from ..storage import Storage
                pass
            else:
                logger.exception(exc)
                raise exc

    def get(self, path):
        with open(os.path.join(self.root_dir, path), 'r') as f:
            return f.read()

    def exists(self, path):
        return os.path.isfile(os.path.join(self.root_dir, path))

    def save(self, path, lines):
        with open(os.path.join(self.root_dir, path), 'a') as f:
            for line in lines:
                f.write(line)

    def mkdir(self, path):
        try:
            os.mkdir(os.path.join(self.root_dir, path))
        except OSError:
            pass

    def get_dirs(self):
        return os.listdir(self.root_dir)

    def get_files(self, path):
        def _file_getctime(filename):
            return os.path.getctime(os.path.join(self.root_dir, path, filename))


# Path: historisation/historisation/storage.py
# class Storage(object):
#     # returns a string with the content of the file or None if it does not exist.
#     def get(self, path):
#         pass
# 
#     # returns true if the file exists
#     def exists(self, path):
#         pass
# 
#     # saves a file-like object at the given location
#     def save(self, path, file):
#         pass
# 
#     # returns a list of directories from the root
#     def get_dirs(self):
#         pass
# 
#     # returns the files from a given directory
#     def get_files(self, path):
#         pass
# 
#     # creates a new directory
#     def mkdir(self, path):
#         pass
# 
#     # moves
#     def move(self, source, dest):
#         pass
# 
#     # join
#     def join(self, *paths):
#         pass


# Path: historisation/historisation/storages/local.py
import os
import errno
import logging
import shutil
from ..storage import Storage

                pass
            else:
                logger.exception(exc)
                raise exc

    def get(self, path):
        with open(os.path.join(self.root_dir, path), 'r') as f:
            return f.read()

    def exists(self, path):
        return os.path.isfile(os.path.join(self.root_dir, path))

    def save(self, path, lines):
        with open(os.path.join(self.root_dir, path), 'a') as f:
            for line in lines:
                f.write(line)

    def mkdir(self, path):
        try:
            os.mkdir(os.path.join(self.root_dir, path))
        except OSError:
            pass

    def get_dirs(self):
        return os.listdir(self.root_dir)

    def get_files(self, path):
        def _file_getctime(filename):
            return os.path.getctime(os.path.join(self.root_dir, path, filename))


        return sorted(os.listdir(os.path.join(self.root_dir, path)), key=_file_getctime)