LAsort.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env python
  2. """Usage:
  3. LAsort.py DB <args>
  4. Run LAcheck on each input in args. Exclude any failures from
  5. the arglist. Then run LAsort on the remaining arglist.
  6. """
  7. import sys
  8. import os
  9. def log(msg):
  10. sys.stderr.write(msg + '\n')
  11. def system(call, checked=False):
  12. log('!{}'.format(call))
  13. rc = os.system(call)
  14. if rc:
  15. msg = '{} <- {!r}'.format(rc, call)
  16. if checked:
  17. raise Exception(msg)
  18. log(msg)
  19. return rc
  20. def main(argv=sys.argv):
  21. log('argv:{!r}'.format(argv))
  22. db = argv[1]
  23. args = argv[2:] # Skip program name
  24. lass = list()
  25. new_args = list()
  26. new_args.append('LAsort')
  27. for arg in args:
  28. if arg.startswith('-'):
  29. new_args.append(arg)
  30. else:
  31. lass.append(arg)
  32. for las in lass:
  33. rc = system('LAcheck -v {} {}.las'.format(db, las))
  34. if rc:
  35. log('Skipping {}.las'.format(las))
  36. else:
  37. new_args.append(las)
  38. system(' '.join(new_args))
  39. if __name__ == "__main__":
  40. main()