[game-data-packager] 01/01: Move make-template CLI to g_d_p.command_line
Simon McVittie
smcv at debian.org
Fri Dec 29 10:53:42 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch master
in repository game-data-packager.
commit 9975a87db46fc011c9357d179f1d9fe45d621e28
Author: Simon McVittie <smcv at debian.org>
Date: Fri Dec 29 10:44:37 2017 +0000
Move make-template CLI to g_d_p.command_line
Signed-off-by: Simon McVittie <smcv at debian.org>
---
debian/changelog | 1 +
game_data_packager/command_line.py | 82 ++++++++++++++++++++++++++++---------
game_data_packager/make_template.py | 25 +----------
run | 14 +------
4 files changed, 65 insertions(+), 57 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 80c30b8..dc218af 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,7 @@ game-data-packager (56) UNRELEASED; urgency=medium
- Fix a typo in previous changelog entry [adetiste]
- Add missing bug reference for #876321 in previous changelog entry
[adetiste]
+ - `g-d-p make-template` now appears in --help output [smcv]
- Make `g-d-p make-template` able to merge new versions into existing
games (the result is very rough and will usually need editing, but
is much less tedious than doing the merge by hand) [smcv]
diff --git a/game_data_packager/command_line.py b/game_data_packager/command_line.py
index f195d96..208d747 100644
--- a/game_data_packager/command_line.py
+++ b/game_data_packager/command_line.py
@@ -20,6 +20,7 @@ import argparse
import logging
import os
import sys
+import textwrap
import time
import zipfile
@@ -80,32 +81,37 @@ class TerminalProgress(ProgressCallback):
def run_command_line():
logger.debug('Arguments: %r', sys.argv)
- # Don't set any defaults on this base parser, because it interferes
+ # Don't set any defaults on these base parsers, because that interferes
# with the ability to recognise the same argument either before or
# after the game name. Set them on the Namespace instead.
base_parser = argparse.ArgumentParser(prog='game-data-packager',
description='Package game files.',
add_help=False,
argument_default=argparse.SUPPRESS)
+ game_parser = argparse.ArgumentParser(prog='game-data-packager',
+ description='Package game files.',
+ add_help=False,
+ argument_default=argparse.SUPPRESS,
+ parents=(base_parser,))
- base_parser.add_argument('--everything', action='store_true',
+ game_parser.add_argument('--everything', action='store_true',
help='Download all possible expansions')
- base_parser.add_argument('--package', '-p', action='append',
+ game_parser.add_argument('--package', '-p', action='append',
dest='packages', metavar='PACKAGE',
help='Produce this data package (may be repeated)')
- base_parser.add_argument('--target-format',
+ game_parser.add_argument('--target-format',
help='Produce packages for this packaging system',
choices='arch deb rpm'.split())
- base_parser.add_argument('--target-distro',
+ game_parser.add_argument('--target-distro',
help='Produce packages suitable for this distro')
- base_parser.add_argument('--install-method', metavar='METHOD',
+ game_parser.add_argument('--install-method', metavar='METHOD',
dest='install_method',
help='Use METHOD (apt, dpkg, gdebi, gdebi-gtk, gdebi-kde) ' +
'to install packages')
- base_parser.add_argument('--gain-root-command', metavar='METHOD',
+ game_parser.add_argument('--gain-root-command', metavar='METHOD',
dest='gain_root_command',
help='Use METHOD (su, sudo, pkexec) to gain root if needed')
@@ -114,37 +120,37 @@ def run_command_line():
# that would rule out the vast majority of its packages: if a game's
# data is Free Software, we could put it in main or contrib and not need
# g-d-p at all.
- base_parser.add_argument('--binary-executables', action='store_true',
+ game_parser.add_argument('--binary-executables', action='store_true',
help='allow installation of executable code that was not built ' +
'from public source code')
# Misc options
- group = base_parser.add_mutually_exclusive_group()
+ group = game_parser.add_mutually_exclusive_group()
group.add_argument('-i', '--install', action='store_true',
help='install the generated package')
group.add_argument('-n', '--no-install', action='store_false',
dest='install',
help='do not install the generated package (requires -d, default)')
- base_parser.add_argument('-d', '--destination', metavar='OUTDIR',
+ game_parser.add_argument('-d', '--destination', metavar='OUTDIR',
help='write the generated .%s(s) to OUTDIR' % FORMAT)
- group = base_parser.add_mutually_exclusive_group()
+ group = game_parser.add_mutually_exclusive_group()
group.add_argument('-z', '--compress', action='store_true',
help='compress generated .%s (default if -d is used)' % FORMAT)
group.add_argument('--no-compress', action='store_false',
dest='compress',
help='do not compress generated .%s (default without -d)' % FORMAT)
- group = base_parser.add_mutually_exclusive_group()
+ group = game_parser.add_mutually_exclusive_group()
group.add_argument('--download', action='store_true',
help='automatically download necessary files if possible ' +
'(default)')
group.add_argument('--no-download', action='store_false',
dest='download', help='do not download anything')
- base_parser.add_argument('--save-downloads', metavar='DIR',
+ game_parser.add_argument('--save-downloads', metavar='DIR',
help='save downloaded files to DIR, and look for files there')
- group = base_parser.add_mutually_exclusive_group()
+ group = game_parser.add_mutually_exclusive_group()
group.add_argument('--search', action='store_true', default=True,
help='look for installed files in Steam and other likely places ' +
'(default)')
@@ -170,7 +176,7 @@ def run_command_line():
def error(self, message):
pass
- dumb_parser = DumbParser(parents=(base_parser,),add_help=False)
+ dumb_parser = DumbParser(parents=(game_parser,),add_help=False)
dumb_parser.add_argument('game', type=str, nargs='?')
dumb_parser.add_argument('paths', type=str, nargs='*')
dumb_parser.add_argument('-h', '--help', action='store_true', dest='h')
@@ -195,7 +201,7 @@ def run_command_line():
games = load_games()
parser = argparse.ArgumentParser(prog='game-data-packager',
- description='Package game files.', parents=(base_parser,),
+ description='Package game files.', parents=(game_parser,),
epilog='Run "game-data-packager GAME --help" to see ' +
'game-specific arguments.')
@@ -203,14 +209,14 @@ def run_command_line():
title='supported games', metavar='GAME')
for g in sorted(games.keys()):
- games[g].add_parser(game_parsers, base_parser)
+ games[g].add_parser(game_parsers, game_parser)
# GOG meta-mode
gog_parser = game_parsers.add_parser('gog',
help='Package all your GOG.com games at once',
description='Automatically package all your GOG.com games',
formatter_class=argparse.RawDescriptionHelpFormatter,
- parents=(base_parser,))
+ parents=(game_parser,))
group = gog_parser.add_mutually_exclusive_group()
group.add_argument('--all', action='store_true', default=False,
help='show all GOG.com games')
@@ -222,13 +228,44 @@ def run_command_line():
help='Package all Steam games at once',
description='Automatically package all your Steam games',
formatter_class=argparse.RawDescriptionHelpFormatter,
- parents=(base_parser,))
+ parents=(game_parser,))
group = steam_parser.add_mutually_exclusive_group()
group.add_argument('--all', action='store_true', default=False,
help='package all Steam games')
group.add_argument('--new', action='store_true', default=False,
help='package all new Steam games')
+ mt_parser = game_parsers.add_parser('make-template',
+ help='Capture details of a new game or update an existing one',
+ description=textwrap.dedent('''\
+ This command collects details of game files in a directory or archive,
+ so that they can be used for a newly supported game or added to an
+ existing game. Please send its output to the Debian bug tracking system
+ as a bug with 'wishlist' severity.\
+ '''),
+ formatter_class=argparse.RawDescriptionHelpFormatter,
+ parents=(base_parser,))
+ mt_parser.add_argument('args', nargs='*', metavar='DEB|DIRECTORY|FILE')
+ mt_parser.add_argument(
+ '--strip-path', action='append', dest='strip_paths', default=[],
+ help='Strip a prefix from all filenames (may be repeated)')
+ mt_parser.add_argument(
+ '--base', default=None, help='Base the template on an existing game')
+ mt_parser.add_argument(
+ '--template', action='append', dest='templates', default=[],
+ help='Load pre-generated templates')
+ mt_parser.add_argument(
+ '-l', '--lower', action='store_true', dest='lower',
+ help='make all files lowercase')
+ mt_parser.add_argument(
+ '-e', '--execute', action='store_true', dest='execute',
+ help='run this game through strace and see which files from '
+ '/usr/share/games or /usr/local/games are needed')
+ mt_parser.add_argument(
+ '-f', '--flacsums', action='store_true', dest='flacsums',
+ help='compute "flacsums" from .wav files')
+ args = parser.parse_args()
+
config = read_config()
parsed = argparse.Namespace(
binary_executables=False,
@@ -267,7 +304,8 @@ def run_command_line():
parser.parse_args(namespace=parsed)
logger.debug('parsed command-line arguments into: %r', parsed)
- if parsed.destination is None and not parsed.install:
+ if (parsed.destination is None and not parsed.install and
+ parsed.shortname != 'make-template'):
logger.error('At least one of --install or --destination is required')
sys.exit(2)
@@ -300,6 +338,10 @@ def run_command_line():
from .gog import (run_gog_meta_mode)
run_gog_meta_mode(parsed, games)
return
+ elif parsed.shortname == 'make-template':
+ import game_data_packager.make_template
+ game_data_packager.make_template.main(parsed, games)
+ return
elif parsed.shortname in games:
game = games[parsed.shortname]
else:
diff --git a/game_data_packager/make_template.py b/game_data_packager/make_template.py
index 8b67691..fb965f0 100644
--- a/game_data_packager/make_template.py
+++ b/game_data_packager/make_template.py
@@ -16,7 +16,6 @@
# You can find the GPL license text on a Debian system under
# /usr/share/common-licenses/GPL-2.
-import argparse
import logging
import os
import subprocess
@@ -930,29 +929,7 @@ def do_flacsums(destdir, lower):
print("\n#processed %i .wav and %i .fla[c] files" % (done_wav, done_flac))
-def main():
- parser = argparse.ArgumentParser(
- description='Produce a template for game-data-packager YAML ' +
- 'based on an existing .deb file or installed directory',
- prog='game-data-packager guess-contents')
- parser.add_argument('args', nargs='*', metavar='DEB|DIRECTORY|FILE')
- parser.add_argument(
- '--strip-path', action='append', dest='strip_paths', default=[],
- help='Strip a prefix from all filenames (may be repeated)')
- parser.add_argument(
- '--base', default=None, help='Base the template on an existing game')
- parser.add_argument(
- '--template', action='append', dest='templates', default=[],
- help='Load pre-generated templates')
- parser.add_argument('-l', '--lower', action='store_true', dest='lower',
- help='make all files lowercase')
- parser.add_argument('-e', '--execute', action='store_true', dest='execute',
- help='run this game through strace and see which files from '
- '/usr/share/games or /usr/local/games are needed')
- parser.add_argument('-f', '--flacsums', action='store_true', dest='flacsums',
- help='compute "flacsums" from .wav files')
- args = parser.parse_args()
-
+def main(args, games):
# ./run make-template -e -- scummvm -p /usr/share/games/spacequest1/ sq1
if args.execute:
do_one_exec(args.args,args.lower)
diff --git a/run b/run
index 31c3c0a..3a09546 100755
--- a/run
+++ b/run
@@ -14,16 +14,4 @@ else
fi
export PYTHONPATH
-if [ $# -eq 0 ]; then
- exec python3 -m game_data_packager.command_line
-fi
-
-case "$1" in
- 'make-template')
- shift
- exec python3 -m game_data_packager.make_template "$@"
- ;;
- *)
- exec python3 -m game_data_packager.command_line "$@"
- ;;
-esac
+exec python3 -m game_data_packager.command_line "$@"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git
More information about the Pkg-games-commits
mailing list