common: convert scripts to python

This commit is contained in:
Ciro Santilli
2018-08-23 09:25:21 +01:00
parent f8c0502bb2
commit 9b30ac217f
6 changed files with 226 additions and 235 deletions

24
getvar
View File

@@ -1,16 +1,8 @@
#!/usr/bin/env bash
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common"
while getopts "h${common_getopts_flags}" OPT; do
case "$OPT" in
h)
echo "https://github.com/cirosantilli/linux-kernel-module-cheat#getvar" 2>&1
exit
;;
?)
common_getopts_case "$OPT"
;;
esac
done
shift "$(($OPTIND - 1))"
common_setup
eval "echo \$common_${1}"
#!/usr/bin/env python3
import common
parser = common.get_argparse(
description='https://github.com/cirosantilli/linux-kernel-module-cheat#getvar'
)
parser.add_argument('variable')
args = common.setup(parser)
print(getattr(common, args.variable))