File indexing completed on 2024-05-19 05:22:17
0001 #!/usr/bin/env python3 0002 0003 import sh 0004 import subprocess 0005 import os 0006 from shutil import copyfile, copy2 0007 from os import path 0008 0009 wantedIcons = [ 0010 "application-menu.svg", 0011 "dialog-cancel.svg", 0012 "dialog-ok.svg", 0013 "document-decrypt.svg", 0014 "document-edit.svg", 0015 "document-encrypt.svg", 0016 "view-certificate-import.svg", 0017 "document-save.svg", 0018 "document-sign.svg", 0019 "edit-delete.svg", 0020 "edit-find.svg", 0021 "edit-undo.svg", 0022 "error.svg", 0023 "folder.svg", 0024 "im-user.svg", 0025 "mail-mark-important.svg", 0026 "mail-mark-unread-new.svg", 0027 "mail-mark-read.svg", 0028 "mail-reply-sender.svg", 0029 "mail-forward.svg", 0030 "mail-folder-outbox.svg", 0031 "network-disconnect.svg", 0032 "view-refresh.svg", 0033 "go-down.svg", 0034 "go-up.svg", 0035 "go-previous.svg", 0036 "go-next.svg", 0037 "mail-message.svg", 0038 "list-add.svg", 0039 "list-remove.svg", 0040 "checkbox.svg", 0041 "edit-copy.svg", 0042 "password-show-on.svg", 0043 "password-show-off.svg", 0044 "format-text-bold-symbolic.svg", 0045 "format-text-italic-symbolic.svg", 0046 "format-text-underline-symbolic.svg", 0047 "documentinfo.svg", 0048 "group.svg", 0049 "mail-task.svg", 0050 "view-calendar.svg", 0051 "question.svg", 0052 "overflow-menu.svg", 0053 "notifications.svg", 0054 "notifications-disabled.svg", 0055 "mail-folder-inbox.svg", 0056 ] 0057 0058 def ensure_dir(file_path): 0059 directory = os.path.dirname(file_path) 0060 if not os.path.exists(directory): 0061 os.makedirs(directory) 0062 0063 def copyFile(rootDir, dir, file): 0064 print("Copy file " + root + ", " + dir + ", " + file) 0065 reldir = dir.replace(path.join(rootDir, "icons"), "") 0066 src = os.path.join(dir, file) 0067 if os.path.islink(src): 0068 # We're dealing with a symlink 0069 linkto = os.readlink(src) 0070 targetRelpath = path.join(os.path.dirname(src), linkto) 0071 targetReldir = os.path.dirname(targetRelpath) 0072 0073 # First recursively copy target 0074 copyFile(rootDir, targetReldir, targetRelpath.replace(targetReldir + "/", "")) 0075 0076 #Create symlinks for normal and dark version 0077 dst = "./breeze/icons" + path.join(reldir, file) 0078 if not os.path.exists(dst): 0079 ensure_dir(dst) 0080 os.symlink(linkto, dst) 0081 0082 invertedDst = "./breeze/icons" + path.join(reldir, file.replace(".svg", "-inverted.svg")) 0083 if not os.path.exists(invertedDst): 0084 ensure_dir(invertedDst) 0085 os.symlink(linkto.replace(".svg", "-inverted.svg"), invertedDst) 0086 else: 0087 # A regular icon, just copy normal and dark version 0088 dst = "./breeze/icons" + path.join(reldir, file) 0089 if not os.path.exists(dst): 0090 print("Copying: " + path.join(dir, file) + " to " + dst) 0091 ensure_dir(dst) 0092 copy2(src, dst) 0093 0094 invertedSrc = src.replace("icons", "icons-dark") 0095 invertedDst = "./breeze/icons" + path.join(reldir, file.replace(".svg", "-inverted.svg")) 0096 if not os.path.exists(invertedDst) and os.path.exists(invertedSrc): 0097 print("Copying: " + src.replace("icons", "icons-dark") + " to " + invertedDst) 0098 ensure_dir(invertedDst) 0099 copy2(invertedSrc, invertedDst) 0100 0101 dir="upstreamBreeze" 0102 if not os.path.exists(dir): 0103 sh.git.clone("--depth", "1", "git://anongit.kde.org/breeze-icons.git", dir) 0104 0105 dirToWalk = dir + "/icons" 0106 for root, dirs, files in os.walk(dirToWalk): 0107 for file in files: 0108 if any(file == s for s in wantedIcons): 0109 copyFile(dir, root, file) 0110 elif "mimetypes" in root: #Except the explicitly mentioned icons we'll also want all mimetypes 0111 copyFile(dir, root, file)