summaryrefslogtreecommitdiff
path: root/branding/scripts/getparam
blob: 005abb1fa599b68d405f5852b7611f0940cd8178 (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
#!/usr/bin/env python3

# A short utility to get appname in compilation time.
# This is a convenience to build helpers while we move the branding mechanism to a separate repo.

import configparser

import os
import sys

from provider import getDefaultProvider
from provider import getProviderData

def getData():
    here = os.path.abspath(os.path.dirname(__file__))
    vendorPath = os.environ.get('VENDOR_PATH')
    configPath = os.path.join(vendorPath, 'vendor.conf')
    if not os.path.isfile(configPath):
        print("ERROR: path does not exist", configPath)
        sys.exit(1)
    config = configparser.ConfigParser()
    config.read(configPath)
    defaultProvider = getDefaultProvider(config)
    return getProviderData(getDefaultProvider(config), config)

if __name__ == "__main__":
    param = sys.argv[1]
    if param == "appname":
        field = "applicationName"
    elif param == "binname":
        field = "binaryName"
    else:
        print("ERROR: unknown param")
        sys.exit(1)
    
    data = getData()
    print(data[field])