Skip to content

Commit

Permalink
fix: directory bug
Browse files Browse the repository at this point in the history
  • Loading branch information
DekunZhang committed Mar 22, 2023
1 parent baf61b2 commit 10de939
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion processor/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

__all__ = ['set_data_dir', 'process']

_data_dir = None
_data_dir: Directory | None = None


def set_data_dir(data_dir):
Expand All @@ -21,7 +21,9 @@ def process(option):
raise ValueError('No data directory set.')
if option['desinventar']['merge']:
merge_controller.start_merging(_data_dir)
_data_dir.update()
if option['desinventar']['slice']:
slice_controller.start_slice(_data_dir)
_data_dir.update()
if option['emdat']['process']:
emdat_controller.start_emdat(_data_dir)
6 changes: 3 additions & 3 deletions processor/_utils/_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self, path: str):
self.__files: list[File] = []
self.__directories: list[Directory] = []
self.__content_names: list[str] = []
self.__update()
self.update()

def __scan_directory(self):
with os.scandir(self.__path) as it:
Expand All @@ -63,7 +63,7 @@ def __scan_directory(self):
elif entry.is_dir():
self.__directories.append(Directory(entry.path))

def __update(self):
def update(self):
self.__files = []
self.__directories = []
self.__scan_directory()
Expand Down Expand Up @@ -153,7 +153,7 @@ def create_subdirectory(self, directory):
if os.path.exists(path):
return
os.makedirs(path)
self.__update()
self.update()

def get_contents(self):
"""Returns a list of the files and subdirectories in the directory."""
Expand Down

0 comments on commit 10de939

Please sign in to comment.