_python 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #compdef python
  2. # Python 2.6
  3. # Python 3.0
  4. local curcontext="$curcontext" state line expl
  5. typeset -A opt_args
  6. local -a args
  7. if _pick_variant python3=Python\ 3 python2 --version; then
  8. args=(
  9. '(-bb)-b[issue warnings about str(bytes_instance), str(bytearray_instance) and comparing bytes/bytearray with str]'
  10. '(-b)-bb[issue errors about str(bytes_instance), str(bytearray_instance) and comparing bytes/bytearray with str]'
  11. )
  12. else
  13. args=(
  14. '-Q+[division options]:division option:(old warn warnall new)'
  15. '(-tt)-t[issue warnings about inconsistent tab usage]'
  16. '(-t)-tt[issue errors about inconsistent tab usage]'
  17. '-3[warn about Python 3.x incompatibilities]'
  18. )
  19. fi
  20. _arguments -C -s -S "$args[@]" \
  21. "-B[don't write .py\[co\] files on import]" \
  22. '(1 -)-c+[program passed in as string (terminates option list)]:python command:' \
  23. '-d[debug output from parser]' \
  24. '-E[ignore PYTHON* environment variables (such as PYTHONPATH)]' \
  25. '(1 * -)-h[display help information]' \
  26. '-i[inspect interactively after running script]' \
  27. '(1 * -)-m[run library module as a script (terminates option list)]:module:->modules' \
  28. '-O[optimize generated bytecode slightly]' \
  29. '-OO[remove doc-strings in addition to the -O optimizations]' \
  30. "-s[don't add user site directory to sys.path]" \
  31. "-S[don't imply 'import site' on initialization]" \
  32. '-u[unbuffered binary stdout and stderr]' \
  33. '-v[verbose (trace import statements)]' \
  34. '(1 * -)'{-V,--version}'[display version information]' \
  35. '-W+[warning control]:warning filter (action\:message\:category\:module\:lineno):(default always ignore module once error)' \
  36. '-x[skip first line of source, allowing use of non-Unix forms of #!cmd]' \
  37. '(-)1:script file:_files -g "*.py(|c|o)(-.)"' \
  38. '*::script argument: _normal' && return
  39. if [[ "$state" = modules ]]; then
  40. local -a modules
  41. modules=(
  42. ${${=${(f)"$(_call_program modules $words[1] -c \
  43. 'from\ pydoc\ import\ help\;\ help\(\"modules\"\)')"}[2,-3]}:#\(package\)}
  44. )
  45. _wanted modules expl module compadd -a modules && return
  46. fi
  47. return 1