From 3cb8f572154d00c742f3a114f08374f09b5103d3 Mon Sep 17 00:00:00 2001 From: "Kali Kaneko (leap communications)" Date: Mon, 1 Jul 2019 19:37:46 +0200 Subject: [refactor] rename things --- branding/scripts/vendorize.py | 99 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100755 branding/scripts/vendorize.py (limited to 'branding/scripts/vendorize.py') diff --git a/branding/scripts/vendorize.py b/branding/scripts/vendorize.py new file mode 100755 index 0000000..46cc1e6 --- /dev/null +++ b/branding/scripts/vendorize.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python3 + +import os +import sys + +from string import Template +import configparser + +OUTFILE = 'config.go' +INFILE = 'config.go.tmpl' +CONFIGFILE = 'config/vendor.conf' +SCRIPT_NAME = 'vendorize' + + +def getProviderData(config): + default = config['default']['provider'] + print("[+] Configured provider:", default) + + c = config[default] + d = dict() + + keys = ('name', 'applicationName', 'binaryName', + 'providerURL', 'tosURL', 'helpURL', + 'donateURL', 'apiURL', 'geolocationAPI', 'caCertString') + + for value in keys: + d[value] = c.get(value) + + return d + + +def addCaData(data, configfile): + provider = data.get('name').lower() + folder, f = os.path.split(configfile) + caFile = os.path.join(folder, provider + '-ca.crt') + if not os.path.isfile(caFile): + bail('[!] Cannot find CA file in {path}'.format(path=caFile)) + with open(caFile) as ca: + data['caCertString'] = ca.read().strip() + + +def writeOutput(data, infile, outfile): + + with open(infile) as infile: + s = Template(infile.read()) + + with open(outfile, 'w') as outf: + outf.write(s.substitute(data)) + + +def bail(msg=None): + if not msg: + print('Usage: {scriptname}.py