s
Size: a a a
s
s
N
¥
N
s
s
¥
#
s
s
#
N
parser = argparse.ArgumentParser(
description='Build PNG files from TTF packages in AUR.')
parser.add_argument('-o', '--output', type=str,
default='html', help='output type')
parser.add_argument('-s', '--source-dir', type=str,
default='/var/aur',
help='directory where ABS/AUR packages live')
parser.add_argument('-b', '--build-dir', type=str,
default='/tmp/archfonts',
help='directory where packages will be copied/built')
args = parser.parse_args()
# Get all ttf packages from the AUR clone.
pkg_dirs = glob.glob(os.path.join(args.source_dir, 'ttf-*'))
ttfs = {}
for pkg_dir in pkg_dirs:
archfont = ArchFontPackage(pkg_dir)
pkg_name = archfont.pkg_name
# Ignore the package if it failed previously.
# This avoids extra work in multiple runs.
if pkg_name in archfont.ignore_list:
continue
# Copy to our build directory
pkg_dir = os.path.join(args.build_dir, pkg_name)
archfont.copy(pkg_dir)
# Try to make the package, add to ignore list if it fails.
ret_code = archfont.make_pkg()
if ret_code != 0:
archfont.ignore_pkg()
continue
# Extract the package we just made, find ttfs and dict' them.
archfont.extract_pkg()
ttf_paths = archfont.get_ttfs()
ttfs[pkg_name] = archfont.to_pngs(ttf_paths)
archfont.trim_pngs(ttfs[pkg_name])
# Write using the html template.
output(ttfs, args.output)
s
N
N
¥
s
s