Dont use chdir() in logo/make.py
This commit is contained in:
parent
9dadd91887
commit
a56475e32f
21
logo/make.py
21
logo/make.py
@ -6,8 +6,12 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
base = os.path.dirname(os.path.abspath(__file__))
|
||||||
src = os.path.abspath('kitty.svg')
|
src = os.path.join(base, 'kitty.svg')
|
||||||
|
|
||||||
|
|
||||||
|
def abspath(x):
|
||||||
|
return os.path.join(base, x)
|
||||||
|
|
||||||
|
|
||||||
def run(*args):
|
def run(*args):
|
||||||
@ -23,18 +27,23 @@ def render(output, sz=256):
|
|||||||
run('optipng', '-quiet', '-o7', '-strip', 'all', output)
|
run('optipng', '-quiet', '-o7', '-strip', 'all', output)
|
||||||
|
|
||||||
|
|
||||||
render('kitty.png')
|
def main():
|
||||||
run('convert', 'kitty.png', '-depth', '8', 'kitty.rgba')
|
render(abspath('kitty.png'))
|
||||||
iconset = 'kitty.iconset'
|
run('convert', abspath('kitty.png'), '-depth', '8', abspath('kitty.rgba'))
|
||||||
|
iconset = abspath('kitty.iconset')
|
||||||
if os.path.exists(iconset):
|
if os.path.exists(iconset):
|
||||||
shutil.rmtree(iconset)
|
shutil.rmtree(iconset)
|
||||||
os.mkdir(iconset)
|
os.mkdir(iconset)
|
||||||
os.chdir(iconset)
|
os.chdir(iconset)
|
||||||
for sz in (16, 32, 64, 128, 256, 512, 1024):
|
for sz in (16, 32, 64, 128, 256, 512, 1024):
|
||||||
iname = 'icon_{0}x{0}.png'.format(sz)
|
iname = os.path.join(iconset, 'icon_{0}x{0}.png'.format(sz))
|
||||||
iname2x = 'icon_{0}x{0}@2x.png'.format(sz // 2)
|
iname2x = 'icon_{0}x{0}@2x.png'.format(sz // 2)
|
||||||
render(iname, sz)
|
render(iname, sz)
|
||||||
if sz > 16 and sz != 128:
|
if sz > 16 and sz != 128:
|
||||||
shutil.copy2(iname, iname2x)
|
shutil.copy2(iname, iname2x)
|
||||||
if sz in (64, 1024):
|
if sz in (64, 1024):
|
||||||
os.remove(iname)
|
os.remove(iname)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user