generate.py 1.5 KB

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