v.build.all.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env python
  2. ############################################################################
  3. #
  4. # MODULE: v.build.all
  5. # AUTHOR(S): Glynn Clements, Radim Blazek
  6. # PURPOSE: Build all vectors in current mapset
  7. # COPYRIGHT: (C) 2004, 2008-2009 by the GRASS Development Team
  8. #
  9. # This program is free software under the GNU General Public
  10. # License (>=v2). Read the file COPYING that comes with GRASS
  11. # for details.
  12. #
  13. #############################################################################
  14. #%module
  15. #% description: Rebuilds topology on all vector maps in the current mapset.
  16. #% keywords: vector
  17. #% keywords: topology
  18. #%end
  19. import sys
  20. from grass.script import core as grass
  21. def main():
  22. env = grass.gisenv()
  23. mapset = env['MAPSET']
  24. ret = 0
  25. vectors = grass.list_grouped('vect')[mapset]
  26. num_vectors = len(vectors)
  27. if grass.verbosity() < 2:
  28. quiet = True
  29. else:
  30. quiet = False
  31. i = 1
  32. for vect in vectors:
  33. map = "%s@%s" % (vect, mapset)
  34. grass.message(_("%s\nBuilding topology for vector map <%s> (%d of %d)...\n%s") % \
  35. ('-' * 80, map, i, num_vectors, '-' * 80))
  36. grass.verbose(_("v.build map=%s") % map)
  37. if grass.run_command("v.build", map = map, quiet = quiet) != 0:
  38. grass.error(_("Building topology for vector map <%s> failed") % map)
  39. ret = 1
  40. i += 1
  41. return ret
  42. if __name__ == "__main__":
  43. options, flags = grass.parser()
  44. sys.exit(main())