fix_typos.sh 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/sh
  2. #
  3. # Derived for GRASS GIS from
  4. # https://trac.osgeo.org/gdal/browser/trunk/gdal/scripts/fix_typos.sh
  5. #
  6. # Run in main source code directory of GRASS GIS:
  7. # sh utils/fix_typos.sh
  8. #
  9. #
  10. ###############################################################################
  11. # $Id$
  12. #
  13. # Project: GDAL
  14. # Purpose: (Interactive) script to identify and fix typos
  15. # Author: Even Rouault <even.rouault at spatialys.com>
  16. #
  17. ###############################################################################
  18. # Copyright (c) 2016, Even Rouault <even.rouault at spatialys.com>
  19. #
  20. # Permission is hereby granted, free of charge, to any person obtaining a
  21. # copy of this software and associated documentation files (the "Software"),
  22. # to deal in the Software without restriction, including without limitation
  23. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  24. # and/or sell copies of the Software, and to permit persons to whom the
  25. # Software is furnished to do so, subject to the following conditions:
  26. #
  27. # The above copyright notice and this permission notice shall be included
  28. # in all copies or substantial portions of the Software.
  29. #
  30. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  31. # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  32. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  33. # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  34. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  35. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  36. # DEALINGS IN THE SOFTWARE.
  37. ###############################################################################
  38. if ! test -d fix_typos; then
  39. # Get our fork of codespell that adds --words-white-list and full filename support for -S option
  40. mkdir fix_typos
  41. cd fix_typos
  42. git clone https://github.com/rouault/codespell
  43. cd codespell
  44. git checkout gdal_improvements
  45. cd ..
  46. # Aggregate base dictionary + QGIS one + Debian Lintian one
  47. curl https://raw.githubusercontent.com/qgis/QGIS/master/scripts/spelling.dat | sed "s/:/->/" | grep -v "colour->" | grep -v "colours->" > qgis.txt
  48. curl https://anonscm.debian.org/cgit/lintian/lintian.git/plain/data/spelling/corrections| grep "||" | grep -v "#" | sed "s/||/->/" > debian.txt
  49. cat codespell/data/dictionary.txt qgis.txt debian.txt | awk 'NF' > grassgis_dict.txt
  50. echo "difered->deferred" >> grassgis_dict.txt
  51. echo "differed->deferred" >> grassgis_dict.txt
  52. cd ..
  53. fi
  54. EXCLUDED_FILES="*/.svn*,configure,config.status,config.sub,*/autom4te.cache/*"
  55. EXCLUDED_FILES="$EXCLUDED_FILES,*/lib/cdhc/doc/goodness.ps,*/lib/cdhc/doc/goodness.tex,*/macosx/pkg/resources/ReadMe.rtf"
  56. EXCLUDED_FILES="$EXCLUDED_FILES,*/lib/gis/FIPS.code,*/lib/gis/projection,*/lib/proj/parms.table,*/lib/proj/units.table,*/lib/proj/desc.table"
  57. EXCLUDED_FILES="$EXCLUDED_FILES,*/locale/po/*.po"
  58. EXCLUDED_FILES="$EXCLUDED_FILES,*/fix_typos/*,fix_typos.sh,*.eps,geopackage_aspatial.html"
  59. EXCLUDED_FILES="$EXCLUDED_FILES,PROVENANCE.TXT,libtool,ltmain.sh,libtool.m4"
  60. WORDS_WHITE_LIST="poSession,FIDN,TRAFIC,HTINK,repID,oCurr,INTREST,oPosition"
  61. WORDS_WHITE_LIST="$WORDS_WHITE_LIST,CPL_SUPRESS_CPLUSPLUS,SRP_NAM,ADRG_NAM,'SRP_NAM,AuxilaryTarget"
  62. # libtiff
  63. WORDS_WHITE_LIST="$WORDS_WHITE_LIST,THRESHHOLD_BILEVEL,THRESHHOLD_HALFTONE,THRESHHOLD_ERRORDIFFUSE"
  64. # GRASS GIS
  65. WORDS_WHITE_LIST="$WORDS_WHITE_LIST,thru"
  66. MYPATH=$(pwd)
  67. touch $MYPATH/fix_typos/typos_whitelist.txt
  68. python3 $MYPATH/fix_typos/codespell/codespell.py -w -i 3 -q 2 -S $EXCLUDED_FILES \
  69. -x $MYPATH/fix_typos/typos_whitelist.txt --words-white-list=$WORDS_WHITE_LIST \
  70. -D $MYPATH/fix_typos/grassgis_dict.txt .