def tree_add(self, path_object: WindowsPath, parentDir, n=0): line = self.indentSpace * n fixedName = path_object.name.replace("_", " ") fixedName = re.sub(r'.md$', '', fixedName) fixedName = fixedName.title() pathName = re.sub(r'.md$', '', path_object.name) if path_object.is_file(): fileContent = self.fileSign.replace("%s", fixedName) + '\n' fileContent = fileContent.replace('%path', parentDir + pathName) self.tree += line + fileContent + '\n' return False elif path_object.is_dir(): self.tree += line + self.dirSign.replace("%s", fixedName) + '\n' return True
def tree_add(self, path_object: WindowsPath, n=0, last=False): if n > 0: if last: self.tree += '│' + (' │' * (n - 1)) + ' └────' + path_object.name else: self.tree += '│' + (' │' * (n - 1)) + ' ├────' + path_object.name else: if last: self.tree += '└' + ('──' * 2) + path_object.name else: self.tree += '├' + ('──' * 2) + path_object.name if path_object.is_file(): self.tree += '\n' return False elif path_object.is_dir(): self.tree += '/\n' return True