roundabout,
created on Monday, 29 April 2024, 06:44:38 (1714373078),
received on Tuesday, 21 May 2024, 13:35:14 (1716298514)
Author identity: vlad <vlad.muntoiu@gmail.com>
d95f101d10f626a3882663cb5c58fc22cc03754b
ampoule_ssg/__init__.py
@@ -36,17 +36,20 @@ def in_directory(directory):
os.chdir(cwd) def delete_directory_contents(directory):def delete_directory_contents(directory, dont_delete: typing.Optional[list[str]] = None):"""Delete all files and directories in a directory recursively, but not the directory itself. :param directory: The directory to clear. :param dont_delete: A list of files and directories to not delete.""" for root, dirs, files in os.walk(directory): for file in files: os.remove(os.path.join(root, file))if file not in dont_delete: os.remove(os.path.join(root, file))for dir in dirs: shutil.rmtree(os.path.join(root, dir))if dir not in dont_delete: shutil.rmtree(os.path.join(root, dir))def parse_date_string(date_string):
@@ -334,11 +337,11 @@ class Site:
return decorator def build(self):def build(self, dont_delete: typing.Optional[list[str]] = None):"""Build the site in its directory.""" # Clear the build directory if it exists. if os.path.isdir(self.build_dir): delete_directory_contents(self.build_dir)delete_directory_contents(self.build_dir, dont_delete=dont_delete)for location, page in self.pages.items(): # Create the required directories. os.makedirs(os.path.join(self.build_dir, os.path.dirname(location)), exist_ok=True)