diff --git a/quail/constants.py b/quail/constants.py index 56d542c..d02db6b 100644 --- a/quail/constants.py +++ b/quail/constants.py @@ -5,4 +5,5 @@ class Constants: ARGUMENT_RM = "--quail_rm" CHECKSUMS_FILE = ".integrity.json" INTEGRITY_IGNORE_FILE = ".integrity_ignore" + UPDATE_IGNORE_FILE = ".quailignore" diff --git a/quail/helper/file_ignore.py b/quail/helper/file_ignore.py index c3af954..5dbed54 100644 --- a/quail/helper/file_ignore.py +++ b/quail/helper/file_ignore.py @@ -31,5 +31,5 @@ def __init__(self, file_path): except FileNotFoundError: self._ignore_list = [] - def accept(self, path): + def is_file_ignored(self, path): return accept_path(path, self._ignore_list) diff --git a/quail/solution/solutioner.py b/quail/solution/solutioner.py index e41a136..d982e3c 100644 --- a/quail/solution/solutioner.py +++ b/quail/solution/solutioner.py @@ -1,5 +1,8 @@ import shutil import os +import glob +from quail.helper.file_ignore import FileIgnore +from quail.constants import Constants class Solutioner: @@ -35,10 +38,24 @@ def install(self): def installed(self): return os.path.exists(self.dest()) + def __update_solution_files(self): + self._solution.open() + fi = FileIgnore(os.path.join(self.dest(), Constants.UPDATE_IGNORE_FILE)) + try: + if not os.path.exists(self.dest()): + os.makedirs(self.dest(), 0o777, True) + for root, dirs, files in self._solution.walk(): + for d in dirs: + if not os.path.exists(d): + os.makedirs(self.dest(root, d), 0o777, True) + for file in files: + if not fi.is_file_ignored(file): + self._retrieve_file(os.path.join(root, file)) + finally: + self._solution.close() + def update(self): - # TODO: uninstall will be a waste of time on future solution types - self.uninstall() - self.install() + self.__update_solution_files() def uninstall(self): if self.installed(): diff --git a/tests/test_ignore_file.py b/tests/test_ignore_file.py new file mode 100644 index 0000000..a93fb73 --- /dev/null +++ b/tests/test_ignore_file.py @@ -0,0 +1,12 @@ +import os +from .base_test_case import BaseTestCase +from quail.constants import Constants +import quail +from quail.solution.solutioner import Solutioner + + +class TestUpdateFileIgnore(BaseTestCase): + + def setUp(self): + super().setUp() + self.solutioner = Solutioner(None, os.path.curdir) diff --git a/tests/test_solution_local.py b/tests/test_solution_local.py index 02c86cd..9ff4f6d 100644 --- a/tests/test_solution_local.py +++ b/tests/test_solution_local.py @@ -1,4 +1,3 @@ - import os import quail from .base_test_solution import BaseTestSolution