mirror of
https://github.com/erkin/ponysay.git
synced 2024-12-01 00:08:00 +01:00
python script for generating tty ponies, for setup
Signed-off-by: Mattias Andrée <maandree@operamail.com>
This commit is contained in:
parent
e2aaeba4ac
commit
7c57ddca51
2 changed files with 36 additions and 28 deletions
31
dev/dist.sh
31
dev/dist.sh
|
@ -1,47 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# USAGE: dev/dist.sh ttyponies
|
||||
# or dev/dist.sh pdfmanual
|
||||
# USAGE: dev/dist.sh pdfmanual
|
||||
# or dev/dist.sh tag VERSION [OTHER OPTIONS FOR `git tag`]
|
||||
# or dev/dist.sh beigepdf
|
||||
# or dev/dist.sh remaster
|
||||
|
||||
|
||||
ttyponies()
|
||||
{
|
||||
defaultinparams="--left - --right - --top - --bottom -"
|
||||
defaultoutparams="--colourful y --left - --right - --top - --bottom - --balloon n --fullcolour y"
|
||||
for x in '' 'extra'; do
|
||||
mkdir -p "${x}ttyponies"
|
||||
for pony in $(find "${x}ponies/" | grep -v '/\.' | grep '\.pony$' | sed -e "s_^${x}ponies/__"); do
|
||||
echo "building ${x}ttypony: $pony"
|
||||
if [ ! -L "${x}ponies/$pony" ]; then
|
||||
ponytool --import ponysay --file "${x}ponies/$pony" $defaultinparams \
|
||||
--export ponysay --platform linux --file "${x}ttyponies/$pony" $defaultoutparams
|
||||
git add "${x}ttyponies/$pony"
|
||||
else
|
||||
ln -sf "$(readlink "${x}ponies/$pony")" "${x}ttyponies/$pony"
|
||||
git add "${x}ttyponies/$pony"
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
remaster()
|
||||
{
|
||||
inparams="--left - --right - --top - --bottom -"
|
||||
xtermoutparams="--left - --right - --top - --bottom - --balloon n"
|
||||
linuxoutparams="--colourful y --left - --right - --top - --bottom - --balloon n --fullcolour y"
|
||||
for x in '' 'extra'; do
|
||||
mkdir -p "${x}ttyponies"
|
||||
for pony in $(find "${x}ponies/" | grep -v '/\.' | grep '\.pony$' | sed -e "s_^${x}ponies/__"); do
|
||||
echo "remastering ${x}pony: $pony"
|
||||
if [ ! -L "${x}ponies/$pony" ]; then
|
||||
ponytool --import ponysay --file "${x}ponies/$pony" $inparams \
|
||||
--export ponysay --file "${x}ponies/$pony" $xtermoutparams \
|
||||
--export ponysay --platform linux --file "${x}ttyponies/$pony" $linuxoutparams
|
||||
git add "${x}ponies/$pony" "${x}ttyponies/$pony"
|
||||
--export ponysay --file "${x}ponies/$pony" $xtermoutparams
|
||||
git add "${x}ponies/$pony"
|
||||
else
|
||||
ln -sf "$(readlink "${x}ponies/$pony")" "${x}ttyponies/$pony"
|
||||
git add "${x}ttyponies/$pony"
|
||||
|
|
33
setup/ttyponies.py
Executable file
33
setup/ttyponies.py
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen
|
||||
|
||||
|
||||
def generateTTY(ponydir, ttyponydir, judge):
|
||||
if ponydir.endswith('/'): ponydir = ponydir[:-1]
|
||||
if ttyponydir.endswith('/'): ttyponydir = ttyponydir[:-1]
|
||||
|
||||
defaultinparams = '--left - --right - --top - --bottom -'.split(' ')
|
||||
defaultoutparams = '--colourful y --left - --right - --top - --bottom - --balloon n --fullcolour y'.split(' ')
|
||||
|
||||
os.makedirs(ttyponydir, Oo755, True)
|
||||
for pony in os.listdir(ponydir):
|
||||
infile = '%s/%s' % ( ponydir, pony)
|
||||
outfile = '%s/%s' % (ttyponydir, pony)
|
||||
if (not pony.endswith('.pony')) or (len(pony) <= 5) or not judge(infile):
|
||||
continue
|
||||
print('Building %s' % outfile)
|
||||
if os.path.islink(infile):
|
||||
os.symlink(os.readlink(infile), outfile)
|
||||
else:
|
||||
cmd = ['ponytool', '--import', 'ponysay', '--file', infile] + defaultinparams
|
||||
cmd += ['--export', 'ponysay', '--platform', 'linux', '--file', outfile] + defaultoutparams
|
||||
Popen(cmd, stdin = sys.stdin, stdout = sys.stdout, stderr = sys.stderr)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
generateTTY(sys.args[1], sys.args[1], lambda _ : True)
|
||||
|
Loading…
Reference in a new issue