Skip to content

Commit

Permalink
Ignore Clade working directory
Browse files Browse the repository at this point in the history
  • Loading branch information
17451k committed Dec 4, 2020
1 parent 2b10fa4 commit 7934d6c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion clade/extensions/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class Extension(metaclass=abc.ABCMeta):

def __init__(self, work_dir, conf=None):
self.name = self.__class__.__name__
self.work_dir = os.path.join(os.path.abspath(str(work_dir)), self.name)
self.clade_work_dir = os.path.abspath(str(work_dir))
self.work_dir = os.path.join(self.clade_work_dir, self.name)
self.conf = conf if conf else dict()
self.temp_dir = None

Expand Down
16 changes: 12 additions & 4 deletions clade/extensions/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class Storage(Extension):
def parse(self, cmds_file):
files_to_add = self.conf.get("Storage.files_to_add", [])

if files_to_add:
self.log("Saving files")

for file in files_to_add:
file = os.path.abspath(file)
self.debug("Adding file: {!r}".format(file))
Expand All @@ -47,10 +50,13 @@ def parse(self, cmds_file):

if os.path.isfile(file):
self.add_file(file)
elif os.path.isdir(file):
for root, _, filenames in os.walk(file):
for filename in filenames:
self.add_file(os.path.join(root, filename))
continue

for root, _, filenames in os.walk(file):
for filename in filenames:
filename = os.path.join(root, filename)
if not filename.startswith(self.clade_work_dir):
self.add_file(filename)

def add_file(self, filename, storage_filename=None, encoding=None):
"""Add file to the storage.
Expand Down Expand Up @@ -78,6 +84,8 @@ def add_file(self, filename, storage_filename=None, encoding=None):
self.__copy_file(filename, dst, encoding=encoding)
except FileNotFoundError as e:
self.debug(e)
except (PermissionError, OSError) as e:
self.log(e)
except shutil.SameFileError:
pass

Expand Down

0 comments on commit 7934d6c

Please sign in to comment.