# Path: flap/util/oofs.py
# class OSFileSystem(FileSystem):
# 
#     def __init__(self):
#         super().__init__()
#         self.current_directory = Path.fromText(os.getcwd())
# 
#     @staticmethod
#     def for_OS(path):
#         return os.path.sep.join([eachPart.fullname()
#                                  for eachPart in path.parts()])
# 
#     def move_to_directory(self, path):
#         os.chdir(self.for_OS(path))
# 
#     def create_file(self, path, content):
#         self._create_path(path)
#         os_path = self.for_OS(path)
#         with open(os_path, "w") as f:
#             f.write(content)
# 
#     def deleteDirectory(self, path):
#         import shutil
#         osPath = self.for_OS(path)
#         if os.path.exists(osPath):
#             shutil.rmtree(osPath)
# 
#     def open(self, path):
#         osPath = self.for_OS(path)
#         if os.path.isdir(osPath):
#             return Directory(self, path)
#         else:
#             return File(self, path, None)
# 
#     def filesIn(self, path):
#         return [self.open(path / each)
#                 for each in os.listdir(self.for_OS(path))]
# 
#     def copy(self, file, destination):
#         import shutil
# 
#         self._create_path(destination)
# 
#         source = self.for_OS(file.path())
#         target = destination if destination.has_extension() \
#             else destination / file.fullname()
# 
#         shutil.copyfile(source, self.for_OS(target))
# 
#     def _create_path(self, path):
#         targetDir = path
#         if path.has_extension():
#             targetDir = path.container()
# 
#         os_target = self.for_OS(targetDir)
#         if not os.path.exists(os_target):
#             os.makedirs(os_target)
# 
#     def load(self, path):
#         assert path, "Invalid path (found '%s')" % path
#         os_path = self.for_OS(path)
#         with open(os_path) as file:
#             return file.read()
# 
# Path: flap/util/path.py
# TEMP = Path.fromText(tempfile.gettempdir())


from unittest import TestCase, main as testmain
from flap.util.oofs import OSFileSystem
from flap.util.path import TEMP
#
# This file is part of Flap.
#
# Flap is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Flap is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Flap.  If not, see <http://www.gnu.org/licenses/>.
#




class OSFileSystemTest(TestCase):

    def setUp(self):
        self.fileSystem = OSFileSystem()

# Path: flap/util/oofs.py
# class OSFileSystem(FileSystem):
# 
#     def __init__(self):
#         super().__init__()
#         self.current_directory = Path.fromText(os.getcwd())
# 
#     @staticmethod
#     def for_OS(path):
#         return os.path.sep.join([eachPart.fullname()
#                                  for eachPart in path.parts()])
# 
#     def move_to_directory(self, path):
#         os.chdir(self.for_OS(path))
# 
#     def create_file(self, path, content):
#         self._create_path(path)
#         os_path = self.for_OS(path)
#         with open(os_path, "w") as f:
#             f.write(content)
# 
#     def deleteDirectory(self, path):
#         import shutil
#         osPath = self.for_OS(path)
#         if os.path.exists(osPath):
#             shutil.rmtree(osPath)
# 
#     def open(self, path):
#         osPath = self.for_OS(path)
#         if os.path.isdir(osPath):
#             return Directory(self, path)
#         else:
#             return File(self, path, None)
# 
#     def filesIn(self, path):
#         return [self.open(path / each)
#                 for each in os.listdir(self.for_OS(path))]
# 
#     def copy(self, file, destination):
#         import shutil
# 
#         self._create_path(destination)
# 
#         source = self.for_OS(file.path())
#         target = destination if destination.has_extension() \
#             else destination / file.fullname()
# 
#         shutil.copyfile(source, self.for_OS(target))
# 
#     def _create_path(self, path):
#         targetDir = path
#         if path.has_extension():
#             targetDir = path.container()
# 
#         os_target = self.for_OS(targetDir)
#         if not os.path.exists(os_target):
#             os.makedirs(os_target)
# 
#     def load(self, path):
#         assert path, "Invalid path (found '%s')" % path
#         os_path = self.for_OS(path)
#         with open(os_path) as file:
#             return file.read()
# 
# Path: flap/util/path.py
# TEMP = Path.fromText(tempfile.gettempdir())


# Path: tests/acceptance/misc.py
from unittest import TestCase, main as testmain
from flap.util.oofs import OSFileSystem
from flap.util.path import TEMP

#
# This file is part of Flap.
#
# Flap is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Flap is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Flap.  If not, see <http://www.gnu.org/licenses/>.
#




class OSFileSystemTest(TestCase):

    def setUp(self):
        self.fileSystem = OSFileSystem()

        self.path = TEMP / "flap_os" / "test.txt"