From c1816075929bd9c18bb09b6c91e2a2b58ab1ee5e Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 31 Oct 2018 12:35:25 +0100 Subject: [PATCH] Remove config patcher Signed-off-by: Knut Ahlers --- Makefile | 12 +----------- requirements.txt | 2 -- update.py | 43 ------------------------------------------- 3 files changed, 1 insertion(+), 56 deletions(-) delete mode 100644 requirements.txt delete mode 100644 update.py diff --git a/Makefile b/Makefile index 4fe3586..6d27a4f 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ chown: ci: full-clean default -build_%: download venv +build_%: download $(MAKE) update_user-config_$* cd tasmota && ../venv/bin/platformio run -e $* mkdir -p build @@ -22,13 +22,3 @@ download: full-clean: clean rm -rf build - -update_user-config_%: venv - ./venv/bin/python update.py config_$*.yml - cd tasmota && git --no-pager diff -w sonoff/user_config.h - -venv: - virtualenv -p python2 venv - ./venv/bin/pip install -r requirements.txt - -.PHONY: venv diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 556a2f4..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -PyYAML -platformio diff --git a/update.py b/update.py deleted file mode 100644 index d91684c..0000000 --- a/update.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python2 -# -*- coding: utf-8 -*- - -import os -import sys - -import yaml - - -def fmt_line(prefix, param, content, comment): - return '{: <47} // {}'.format('{}#define {: <22} {}'.format(prefix, param, content), comment) - - -def get_line(param, content, comment): - if content == '!undef': - return fmt_line('//', param, '', comment) - if content == '!def': - return fmt_line('', param, '', comment) - - if content[:2] == '${': - envvar = content.strip('${}') - if envvar in os.environ: - content = os.environ[envvar] - - return fmt_line('', param, content, comment) - - -def main(): - cfg = yaml.load(open(sys.argv[1])) - config = open('tasmota/sonoff/user_config.h').read().split('\n') - - for (i, line) in enumerate(config): - for param, content in cfg.items(): - if '#define {} '.format(param) in line: - comment = line.lstrip('/').split(' //', 1)[1].strip() - config[i] = get_line(param, content, comment) - - with open('tasmota/sonoff/user_config.h', 'w') as fh: - fh.write('\n'.join(config)) - - -if __name__ == '__main__': - main()