-
Notifications
You must be signed in to change notification settings - Fork 53
/
build_dropbox.py
29 lines (24 loc) · 1.38 KB
/
build_dropbox.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import sys
import gi
gi.require_version('GdkPixbuf', '2.0')
from gi.repository import GdkPixbuf
import re
def replace_many(src2dest, buf):
src_re = re.compile('|'.join(re.escape(word) for word in src2dest))
def replace_repl(mo):
return src2dest[mo.group()]
return src_re.sub(replace_repl, buf)
if __name__ == '__main__':
pixbuf64 = GdkPixbuf.Pixbuf.new_from_file("data/icons/hicolor/64x64/apps/dropbox.png")
pixbuf16 = GdkPixbuf.Pixbuf.new_from_file("data/icons/hicolor/16x16/apps/dropbox.png")
src2dest = {'@PACKAGE_VERSION@': sys.argv[1],
'@DESKTOP_FILE_DIR@': sys.argv[2],
'@IMAGEDATA64@': ("GdkPixbuf.Pixbuf.new_from_data(%r, GdkPixbuf.Colorspace.RGB, %r, %r, %r, %r, %r)" %
(pixbuf64.get_pixels(), pixbuf64.get_has_alpha(), pixbuf64.get_bits_per_sample(),
pixbuf64.get_width(), pixbuf64.get_height(), pixbuf64.get_rowstride())),
'@IMAGEDATA16@': ("GdkPixbuf.Pixbuf.new_from_data(%r, GdkPixbuf.Colorspace.RGB, %r, %r, %r, %r, %r)" %
(pixbuf16.get_pixels(), pixbuf16.get_has_alpha(), pixbuf16.get_bits_per_sample(),
pixbuf16.get_width(), pixbuf16.get_height(), pixbuf16.get_rowstride())),
}
buf = sys.stdin.read()
sys.stdout.write(replace_many(src2dest, buf))