postprocessing_py.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash
  2. set -eu
  3. # Performs Maps specific post-processing on a .tar.gz archive
  4. use_map_namespace() {
  5. f="${1}/setup.py"
  6. sed -e "s/google.cloud/google.maps/g" "${f}" > "${f}.new" && mv "${f}.new" "${f}"
  7. }
  8. use_markdown_readme() {
  9. f="${1}/setup.py"
  10. sed -e "s/README.rst/README.md/g" "${f}" > "${f}.new" && mv "${f}.new" "${f}"
  11. rm -f "${1}/README.rst"
  12. }
  13. update_python_versions() {
  14. f="${1}/setup.py"
  15. sed -e "/Python :: 2/d" "${f}" > "${f}.new" && mv "${f}.new" "${f}"
  16. sed -e "/Python :: 3.4/d" "${f}" > "${f}.new" && mv "${f}.new" "${f}"
  17. sed -e "/enum34/d" "${f}" > "${f}.new" && mv "${f}.new" "${f}"
  18. sed -e "s/'Programming Language :: Python :: 3.6',/'Programming Language :: Python :: 3.6',\n 'Programming Language :: Python :: 3.7',/g" "${f}" > "${f}.new" && mv "${f}.new" "${f}"
  19. }
  20. # Main entry point
  21. #
  22. # Arguments:
  23. # postprocess_dir: The directory that contains the Java files to postprocess.
  24. main() {
  25. postprocess_dir="$1"
  26. if [ "${postprocess_dir}" = "" ]; then
  27. echo "postprocess_dir is required"
  28. exit 1
  29. fi
  30. use_markdown_readme "${postprocess_dir}"
  31. update_python_versions "${postprocess_dir}"
  32. use_map_namespace "${postprocess_dir}"
  33. }
  34. main "$@"