Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed changeset for "Update delete the whole solution to install it again" #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions quail/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ class Constants:
ARGUMENT_RM = "--quail_rm"
CHECKSUMS_FILE = ".integrity.json"
INTEGRITY_IGNORE_FILE = ".integrity_ignore"
UPDATE_IGNORE_FILE = ".quailignore"

2 changes: 1 addition & 1 deletion quail/helper/file_ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
23 changes: 20 additions & 3 deletions quail/solution/solutioner.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import shutil
import os
import glob
from quail.helper.file_ignore import FileIgnore
from quail.constants import Constants


class Solutioner:
Expand Down Expand Up @@ -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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get .quailignore

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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore ici

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():
Expand Down
12 changes: 12 additions & 0 deletions tests/test_ignore_file.py
Original file line number Diff line number Diff line change
@@ -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)
1 change: 0 additions & 1 deletion tests/test_solution_local.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import os
import quail
from .base_test_solution import BaseTestSolution
Expand Down