mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-12-23 03:41:55 +00:00
Fix files in subdirectories killing everything I stand for
This commit is contained in:
parent
d0a04240b6
commit
c2c5353f98
@ -1,5 +1,5 @@
|
||||
from shutil import copy, rmtree, copytree
|
||||
from os.path import splitext, isfile, join, basename
|
||||
from os.path import splitext, isfile, join, relpath
|
||||
from glob import glob
|
||||
|
||||
from tfw.util import SupervisorMixin
|
||||
@ -15,7 +15,7 @@ class FileManager:
|
||||
self._sourcedir = source_directory
|
||||
self._workdir = working_directory
|
||||
self._reload_files()
|
||||
self.filename = selected_file or basename(self.files[0])
|
||||
self.filename = selected_file or self._relpath(self.files[0])
|
||||
self.language = map_file_extension_to_language(self.filename)
|
||||
|
||||
def select_file(self, filename):
|
||||
@ -26,7 +26,7 @@ class FileManager:
|
||||
|
||||
@property
|
||||
def files(self):
|
||||
return [basename(file) for file in glob(join(self._workdir, '**/*'), recursive=True) if isfile(file)]
|
||||
return [self._relpath(file) for file in glob(join(self._workdir, '**/*'), recursive=True) if isfile(file)]
|
||||
|
||||
@property
|
||||
def file_contents(self):
|
||||
@ -41,6 +41,9 @@ class FileManager:
|
||||
def _filepath(self, filename):
|
||||
return join(self._workdir, filename)
|
||||
|
||||
def _relpath(self, filename):
|
||||
return relpath(self._filepath(filename), start=self._workdir)
|
||||
|
||||
def _reload_files(self):
|
||||
rmtree(self._workdir, ignore_errors=True)
|
||||
copytree(self._sourcedir, self._workdir)
|
||||
|
Loading…
Reference in New Issue
Block a user