| --- breeze-icons-5.75.0/generate-24px-versions.py.orig 2020-10-04 12:45:37.000000000 +0300 |
| +++ breeze-icons-5.75.0/generate-24px-versions.py 2020-10-20 12:26:13.317337400 +0300 |
| @@ -6,6 +6,7 @@ |
| """ |
| import os |
| import re |
| +import shutil |
| import sys |
| from pathlib import Path |
| from lxml import etree |
| @@ -64,6 +65,27 @@ |
| namespaces=NAMESPACES |
| ) |
| |
| +def symlink_or_copy(source, destination): |
| + src_path = Path(source) |
| + dest_path = Path(destination) |
| + target_is_directory=src_path.is_dir() |
| + if dest_path.exists(): |
| + if dest_path.is_symlink(): |
| + os.unlink(str(dest_path)) |
| + elif dest_path.is_dir(): |
| + shutil.rmtree(str(dest_path)) |
| + else: |
| + os.unlink(str(dest_path)) |
| + |
| + if sys.platform == 'win32': |
| + if target_is_directory: |
| + shutil.copytree(str(src_path), str(dest_path)) |
| + else: |
| + shutil.copyfile(str(src_path), str(dest_path)) |
| + else: |
| + if os.path.islink(dest_path): |
| + os.remove(dest_path) |
| + os.symlink(symlink_source, file_destination, target_is_directory) |
| |
| def main(): |
| for dirpath, dirnames, filenames in os.walk(INPUT_DIR): |
| @@ -78,10 +100,11 @@ |
| |
| # Make 24@2x/ and 24@3x/ |
| for scale in (2, 3): |
| - folder24_scaled_destination = folder24_destination.replace('/24', f'/24@{scale}x') |
| - if os.path.islink(folder24_scaled_destination): |
| - os.remove(folder24_scaled_destination) |
| - os.symlink("24", folder24_scaled_destination, target_is_directory=True) |
| + if scale == 3: |
| + folder24_scaled_destination = folder24_destination.replace('/24', f'/24x@{scale}x') |
| + else: |
| + folder24_scaled_destination = folder24_destination.replace('/24', f'/24@{scale}x') |
| + symlink_or_copy(folder24_destination, folder24_scaled_destination) |
| # print(folder24_scaled_destination + " -> " + os.readlink(folder24_scaled_destination)) |
| |
| for f in filenames: |