From 4446c33fd2998d7f27ea920236152d48db4cfad9 Mon Sep 17 00:00:00 2001 From: Dendy Faist Date: Sat, 24 Feb 2024 13:45:52 +0100 Subject: [PATCH] Sort the entries alphabetically --- src/files.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/files.py b/src/files.py index 83971e8..f02d875 100644 --- a/src/files.py +++ b/src/files.py @@ -67,6 +67,9 @@ class DocumentNode(): if file not in children: children.append(DocumentNode(file, [])) + # With this algorithm they're not properly sorted + children.sort(key=lambda x: x.name) + return DocumentNode(path.split('/')[-1], children) @@ -98,7 +101,7 @@ class DocumentTree(): internal_path = os.path.join(self.base, *path.split('/')) + '.md' # TODO: Probably add some sort of confirmation beforehand? - os.makedirs(os.path.dirname(internal_path)) + os.makedirs(os.path.dirname(internal_path), exist_ok=True) with open(internal_path, 'w') as file: file.write(text)