generate.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. FILES = {'oc_obj.py': ['src/base.py',
  16. '../../lib_yaml_editor/build/src/yedit.py',
  17. 'src/obj.py',
  18. 'ansible/obj.py',
  19. ],
  20. 'oc_secret.py': ['src/base.py',
  21. '../../lib_yaml_editor/build/src/yedit.py',
  22. 'src/secret.py',
  23. 'ansible/secret.py',
  24. ],
  25. }
  26. def main():
  27. ''' combine the necessary files to create the ansible module '''
  28. openshift_ansible = ('../library/')
  29. for fname, parts in FILES.items():
  30. with open(os.path.join(openshift_ansible, fname), 'w') as afd:
  31. afd.seek(0)
  32. afd.write(GEN_STR)
  33. for fpart in parts:
  34. with open(fpart) as pfd:
  35. # first line is pylint disable so skip it
  36. for idx, line in enumerate(pfd):
  37. if idx == 0 and 'skip-file' in line:
  38. continue
  39. afd.write(line)
  40. if __name__ == '__main__':
  41. main()