summaryrefslogtreecommitdiffstats
path: root/roles/lib_openshift_api/build/generate.py
blob: 877ca17666a0b61e2cb90a9d82e69ea1374fb172 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
'''
  Generate the openshift-ansible/roles/lib_openshift_cli/library/ modules.
'''

import os

# pylint: disable=anomalous-backslash-in-string
GEN_STR = "#!/usr/bin/env python\n"                                   + \
          "#     ___ ___ _  _ ___ ___    _ _____ ___ ___\n"          + \
          "#    / __| __| \| | __| _ \  /_\_   _| __|   \\\n"        + \
          "#   | (_ | _|| .` | _||   / / _ \| | | _|| |) |\n"        + \
          "#    \___|___|_|\_|___|_|_\/_/_\_\_|_|___|___/_ _____\n"  + \
          "#   |   \ / _ \  | \| |/ _ \_   _| | __|   \_ _|_   _|\n" + \
          "#   | |) | (_) | | .` | (_) || |   | _|| |) | |  | |\n"   + \
          "#   |___/ \___/  |_|\_|\___/ |_|   |___|___/___| |_|\n"



FILES = {'oc_obj.py': ['src/base.py',
                       '../../lib_yaml_editor/build/src/yedit.py',
                       'src/obj.py',
                       'ansible/obj.py',
                      ],
         'oc_secret.py': ['src/base.py',
                          '../../lib_yaml_editor/build/src/yedit.py',
                          'src/secret.py',
                          'ansible/secret.py',
                         ],
        }


def main():
    ''' combine the necessary files to create the ansible module '''
    openshift_ansible = ('../library/')
    for fname, parts in FILES.items():
        with open(os.path.join(openshift_ansible, fname), 'w') as afd:
            afd.seek(0)
            afd.write(GEN_STR)
            for fpart in parts:
                with open(fpart) as pfd:
                    # first line is pylint disable so skip it
                    for idx, line in enumerate(pfd):
                        if idx == 0 and 'skip-file' in line:
                            continue

                        afd.write(line)


if __name__ == '__main__':
    main()