build: do not recreate images in install phase (#88254)
gitea/publik-base-theme/pipeline/head Build queued... Details

This commit is contained in:
Frédéric Péters 2024-03-15 22:45:15 +01:00
parent 20faa54dc6
commit e3cff5cc9f
3 changed files with 14 additions and 0 deletions

View File

@ -162,6 +162,9 @@ class build_icons(Command):
'python3 src/render-imgs-dashboard.py static/somme-cd80/img/ --normal 4D4D4D '
'--selected 87A738 --title FFFFFF --title-width 80',
]
if self.distribution.commands == ['install']:
cmds = [f'{x} --skip-existing' for x in cmds]
if not os.path.exists('static/tournai/img'):
os.mkdir('static/tournai/img')
for image in glob.glob('static/tournai/assets/*.svg'):

View File

@ -92,6 +92,7 @@ parser = argparse.ArgumentParser()
parser.add_argument('path', help='out path')
parser.add_argument('--primary', default='E0037A')
parser.add_argument('--secondary', default='6D1F80')
parser.add_argument('--skip-existing', action='store_true')
args = parser.parse_args()
path_out = args.path
@ -100,6 +101,12 @@ os.makedirs(path_out, exist_ok=True)
for filename in filenames:
outname = names.get(re.search(r'\d+', filename).group())
if (
args.skip_existing
and os.path.exists(os.path.join(path_out, '%s.png' % outname))
and os.path.exists(os.path.join(path_out, '%s-on.png' % outname))
):
continue
fd = open('tmp-%s.svg' % outname, 'w')
fd.write(

View File

@ -56,6 +56,7 @@ parser.add_argument('--selected-width')
parser.add_argument('--title')
parser.add_argument('--title-height')
parser.add_argument('--title-width')
parser.add_argument('--skip-existing', action='store_true')
args = parser.parse_args()
path_out = args.path
@ -88,6 +89,9 @@ for filename in filenames:
else:
out_filepath = os.path.join(path_out, '%s.png' % icon_name)
if args.skip_existing and os.path.exists(out_filepath):
continue
for node in tree.iter():
tag_name = node.tag.split('}')[-1]
if tag_name == 'path':