def restore(self):
<EOL>structure = self._get_structure()<EOL>list_of_key = list(structure.keys())<EOL>structure = structure[list_of_key[<NUM_LIT:0>]]<EOL>parent_path = list_of_key[<NUM_LIT:0>]<EOL>if not parent_path.endswith(PyFunceble.directory_separator):<EOL><INDENT>parent_path += PyFunceble.directory_separator<EOL><DEDENT>replacement_status = self._restore_replace()<EOL>for directory in structure:<EOL><INDENT>base = self.base + parent_path + directory<EOL>if not base.endswith(PyFunceble.directory_separator):<EOL><INDENT>base += PyFunceble.directory_separator<EOL><DEDENT>self._create_directory(base)<EOL>for file in structure[directory]:<EOL><INDENT>file_path = base + file<EOL>content_to_write = structure[directory][file]["<STR_LIT:content>"]<EOL>online_sha = structure[directory][file]["<STR_LIT>"]<EOL>content_to_write = Regex(<EOL>content_to_write, "<STR_LIT>", escape=True, replace_with="<STR_LIT>"<EOL>).replace()<EOL>git_to_keep = file_path.replace("<STR_LIT>", "<STR_LIT>")<EOL>keep_to_git = file_path.replace("<STR_LIT>", "<STR_LIT>")<EOL>if replacement_status:<EOL><INDENT>if (<EOL>PyFunceble.path.isfile(file_path)<EOL>and Hash(file_path, "<STR_LIT>", True).get() == online_sha<EOL>):<EOL><INDENT>PyFunceble.rename(file_path, git_to_keep)<EOL>write = False<EOL><DEDENT>else:<EOL><INDENT>File(file_path).delete()<EOL>file_path = git_to_keep<EOL>write = True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if (<EOL>PyFunceble.path.isfile(keep_to_git)<EOL>and Hash(file_path, "<STR_LIT>", True).get() == online_sha<EOL>):<EOL><INDENT>PyFunceble.rename(file_path, keep_to_git)<EOL>write = False<EOL><DEDENT>else:<EOL><INDENT>File(keep_to_git).delete()<EOL>file_path = keep_to_git<EOL>write = True<EOL><DEDENT><DEDENT>if write:<EOL><INDENT>File(file_path).write(content_to_write + "<STR_LIT:\n>", True)<EOL><DEDENT><DEDENT><DEDENT>self.delete_uneeded()<EOL>
Restore the 'output/' directory structure based on the `dir_structure.json` file.