File: all_images.py

package info (click to toggle)
unknown-horizons 2019.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 347,832 kB
  • sloc: python: 46,804; xml: 3,137; sql: 1,189; sh: 736; makefile: 40; perl: 35
file content (58 lines) | stat: -rwxr-xr-x 2,022 bytes parent folder | download | duplicates (4)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3

# ###################################################
# Copyright (C) 2008-2017 The Unknown Horizons Team
# team@unknown-horizons.org
# This file is part of Unknown Horizons.
#
# Unknown Horizons is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# ###################################################

'''
Generate html output for a page displaying all images currently available
in the repository and in a certain directory. Does not wite anything to a
file, you will need to redirect output.
Change `where` below to anything else as you see fit.
'''
from __future__ import print_function

import os
import os.path


# All gui images and icons
where = 'content/gui/'

# All atlas files
# where = 'content/gfx/atlas/'

# All building, unit and other images (including atlas files)
# Warning: This most likely is too huge to be of any help.
# where = 'content/gfx/'

# make this script work both when started inside development and in the uh root dir
if not os.path.exists('content'):
	os.chdir('..')
assert os.path.exists('content'), 'Content dir not found.'

base_url = 'file://localhost/' + os.path.abspath(os.getcwd()) + '/'

for root, dirs, files in sorted(os.walk(where)):
	for f in sorted(files):
		if not f.endswith(('.png', '.jpg')):
			continue
		url = base_url + '/' + root + '/' + f
		print('<a href="{url}"><img src="{url}" /></a>'.format(url=url))