File: gen.py

package info (click to toggle)
azure-cli 2.82.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,359,416 kB
  • sloc: python: 1,910,381; sh: 1,343; makefile: 406; cs: 145; javascript: 74; sql: 37; xml: 21
file content (42 lines) | stat: -rw-r--r-- 1,205 bytes parent folder | download | duplicates (3)
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
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

"""
Generate CLITest.yml in ./
"""


import os

from jinja2 import Environment, FileSystemLoader

# If include extensions
EXTENSION = False


def main():
    env = Environment(loader=FileSystemLoader('/mnt/vss/_work/1/s/scripts/live_test/'))
    template = env.get_template('template.yml')
    config = {}
    config['modules'] = get_modules()
    result = template.render(config)
    with open('CLITest.yml', 'w') as f:
        f.write(result)


def get_modules():
    """
    :return: str[]
    """
    path = 'azure-cli/src/azure-cli/azure/cli/command_modules'
    modules = [m for m in os.listdir(path) if os.path.isdir(os.path.join(path, m))]
    if EXTENSION:
        path = 'azure-cli-extensions/src'
        modules.extend(m for m in os.listdir(path) if os.path.isdir(os.path.join(path, m)))
    return modules


if __name__ == '__main__':
    main()