mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 03:53:32 +01:00
python-tools.sh: Add python-tools.sh
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
d49340917b
commit
9505e9ab40
1 changed files with 58 additions and 0 deletions
58
scripts/python-tools.sh
Normal file
58
scripts/python-tools.sh
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
usage()
|
||||||
|
{
|
||||||
|
cat <<-EOT
|
||||||
|
|
||||||
|
usage $myname [-e sed-extract-command] [-m module] file.py ...
|
||||||
|
|
||||||
|
EOT
|
||||||
|
[ "$1" ] && exit $1
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_create_init()
|
||||||
|
{
|
||||||
|
local f files base extracted
|
||||||
|
files="$*"
|
||||||
|
for f in $files; do
|
||||||
|
base=${f##*/}
|
||||||
|
base=${base%.py}
|
||||||
|
if [ "$sed_extract_command" ]; then
|
||||||
|
#echo running $sed_extract_command on $f
|
||||||
|
extracted=`sed "$sed_extract_command" $f`
|
||||||
|
if [ "$extracted" ]; then
|
||||||
|
echo "from $module.$base import $extracted"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# --------------------- here we go
|
||||||
|
|
||||||
|
myname=`basename $0`
|
||||||
|
|
||||||
|
eval set -- `getopt -o 'he:m:' "$@"`
|
||||||
|
while [ "$1" != -- ]; do
|
||||||
|
case $1 in
|
||||||
|
-e)
|
||||||
|
sed_extract_command=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-m)
|
||||||
|
module=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-h)
|
||||||
|
usage 0;;
|
||||||
|
*)
|
||||||
|
echo unknown argument $1
|
||||||
|
usage 1;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
shift
|
||||||
|
|
||||||
|
cmd=cmd_${1//-/_}
|
||||||
|
shift
|
||||||
|
|
||||||
|
eval $cmd $*
|
||||||
Loading…
Add table
Add a link
Reference in a new issue