check_a3m.py 437 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env python
  2. from a3m import A3M_Container
  3. from a3m import A3MFormatError
  4. import sys
  5. def check_a3m(filename):
  6. a3m = A3M_Container()
  7. if(filename.lower() == "stdin"):
  8. fh = sys.stdin
  9. else:
  10. fh = open(filename, "r")
  11. try:
  12. a3m.read_a3m(fh)
  13. except A3MFormatError as e:
  14. sys.stderr.write(str(e))
  15. exit(1)
  16. def main():
  17. filename = sys.argv[1]
  18. check_a3m(filename)
  19. if __name__ == "__main__":
  20. main()