generate.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env python
  2. '''
  3. Generate the openshift-ansible/roles/lib_openshift_cli/library/ modules.
  4. '''
  5. import os
  6. # pylint: disable=anomalous-backslash-in-string
  7. GEN_STR = "#!/usr/bin/env python\n" + \
  8. "# ___ ___ _ _ ___ ___ _ _____ ___ ___\n" + \
  9. "# / __| __| \| | __| _ \ /_\_ _| __| \\\n" + \
  10. "# | (_ | _|| .` | _|| / / _ \| | | _|| |) |\n" + \
  11. "# \___|___|_|\_|___|_|_\/_/_\_\_|_|___|___/_ _____\n" + \
  12. "# | \ / _ \ | \| |/ _ \_ _| | __| \_ _|_ _|\n" + \
  13. "# | |) | (_) | | .` | (_) || | | _|| |) | | | |\n" + \
  14. "# |___/ \___/ |_|\_|\___/ |_| |___|___/___| |_|\n"
  15. OPENSHIFT_ANSIBLE_PATH = os.path.dirname(os.path.realpath(__file__))
  16. FILES = {'yedit.py': ['src/base.py', 'src/yedit.py', 'ansible/yedit.py'],
  17. }
  18. def main():
  19. ''' combine the necessary files to create the ansible module '''
  20. library = os.path.join(OPENSHIFT_ANSIBLE_PATH, '..', 'library/')
  21. for fname, parts in FILES.items():
  22. with open(os.path.join(library, fname), 'w') as afd:
  23. afd.seek(0)
  24. afd.write(GEN_STR)
  25. for fpart in parts:
  26. with open(os.path.join(OPENSHIFT_ANSIBLE_PATH, fpart)) as pfd:
  27. # first line is pylint disable so skip it
  28. for idx, line in enumerate(pfd):
  29. if idx == 0 and 'skip-file' in line:
  30. continue
  31. afd.write(line)
  32. if __name__ == '__main__':
  33. main()