diff --git a/scripts/python-tools.sh b/scripts/python-tools.sh index dc4c19c7..657204da 100644 --- a/scripts/python-tools.sh +++ b/scripts/python-tools.sh @@ -49,14 +49,13 @@ cmd_create_init() echo "" echo "__path__ = extend_path(__path__, __name__)" echo - local f local -A seen=() - local dst_type - for f in $files; do - test -d $f && continue - local base=${f##*/} - base=${base%.py} - if [ "$sed_extract_cmd" ]; then + local f dst_type + if [ "$sed_extract_cmd" ]; then + for f in $files; do + test -d $f && continue + local base=${f##*/} + base=${base%.py} local src_type types=$(sed "$sed_extract_cmd" $f) for src_type in $types; do if [ -z "$sed_symbol_filter_cmd" ]; then @@ -64,12 +63,11 @@ cmd_create_init() else dst_type=$(echo $base $src_type | sed "$sed_symbol_filter_cmd") fi - [ "$sed_symbol_filter_cmd" ] && dst_type=$(echo $base $src_type | sed "$sed_symbol_filter_cmd") echo "from `module_path $base` import $src_type as $dst_type" __add_seen $dst_type done - fi - done + done + fi if [ "$import_submodules" = 1 ]; then for f in $files; do [ -f $f/__init__.py ] || continue @@ -92,10 +90,10 @@ cmd_create_init() myname=`basename $0` -eval set -- `getopt -l 'symbol-filter:' -o 'he:m:' "$@"` +eval set -- `getopt -l 'symbol-filter:,extract-filter:,module:' -o 'he:m:' "$@"` while [ "$1" != -- ]; do case $1 in - -e) + -e|--extract-filter) sed_extract_cmd="$2" shift ;; @@ -103,15 +101,17 @@ case $1 in sed_symbol_filter_cmd="$2" shift ;; - -m) + -m|--module) module=$2 shift ;; - -h) - usage 0;; + -h|--help) + usage 0 + ;; *) - echo unknown argument $1 - usage 1;; + echo "Unknown argument $1" + usage 1 + ;; esac shift done