OpenStack IRC meetings schedule
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

check_chair.py 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/usr/bin/env python
  2. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  3. # not use this file except in compliance with the License. You may obtain
  4. # a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software
  9. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  10. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  11. # License for the specific language governing permissions and limitations
  12. # under the License.
  13. from __future__ import print_function
  14. import argparse
  15. import re
  16. import sys
  17. from yaml2ical import meeting
  18. BOOL_STR = {True: 'OK', False: 'Needs Fixing'}
  19. def check_chair(chair):
  20. if re.search(r',', chair):
  21. chairs = chair.split(',')
  22. else:
  23. chairs = [chair]
  24. all_good = True
  25. msg = ''
  26. for chair in chairs:
  27. chair = chair.rstrip().lstrip()
  28. ok = bool(re.match(r"^[\w '.-]+\([\w\d_-]+\)$", chair))
  29. all_good &= ok
  30. msg += "\t%s: %s\n" % (chair, BOOL_STR[ok])
  31. return (all_good, msg)
  32. def main():
  33. # build option parser:
  34. description = """
  35. A tool that checks a meeting chair matches the canonical format.
  36. """
  37. parser = argparse.ArgumentParser(
  38. formatter_class=argparse.RawDescriptionHelpFormatter,
  39. description=description)
  40. parser.add_argument("-y", "--yamldir",
  41. dest="yaml_dir",
  42. required=True,
  43. help="directory containing YAML to process")
  44. args = parser.parse_args()
  45. meetings = meeting.load_meetings(args.yaml_dir)
  46. return_code = 0
  47. for m in meetings:
  48. ok, msg = check_chair(m.chair)
  49. if not ok:
  50. return_code = 1
  51. print(m.filefrom)
  52. print(msg.rstrip())
  53. return return_code
  54. if __name__ == '__main__':
  55. sys.exit(main())