From 59730d52baa810527f1a2344135b76b54c42beea Mon Sep 17 00:00:00 2001 From: Jan--Henrik Date: Tue, 7 May 2019 03:36:09 +0200 Subject: [PATCH 1/3] added patcher --- patch.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 patch.py diff --git a/patch.py b/patch.py new file mode 100755 index 0000000..84c3099 --- /dev/null +++ b/patch.py @@ -0,0 +1,19 @@ +#!/bin/python3.6 +import sys + +patch=open(sys.argv[1], "r").readlines() +orig=open(sys.argv[2],"r") +origlines = orig.readlines() + +for idx,oline in enumerate(origlines): + subst = oline.split('=') + for idx1,pline in enumerate(patch): + if subst[0] in pline: + origlines[idx] = pline + patch.pop(idx1) +origlines += patch +orig.close + +new=open(sys.argv[2],"w") +new.writelines(origlines) +new.close From 6d3b2ea9b4079af5ea121181fdf72fc3f574405d Mon Sep 17 00:00:00 2001 From: Jan--Henrik Date: Tue, 7 May 2019 03:43:00 +0200 Subject: [PATCH 2/3] updated README --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index ea72672..7ea6ece 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,16 @@ Use a text editor to overwrite the relevant sections with the data found in the The pcbnew config file content has been split into the sections responsible for the footprint editor and the one for pcbnew. This is done to allow you to more easily mix and match different schemes for different tools. +## Automatic patcher + +You can use patch.py to automatically patch the configuration files. The python script searches for settings that have to be overwritten and appends all new settings to the end of the file. + +`python3.6 patch.py ` + +For example: + +`python3.6 patch.py ~/kicad-color-schemes/blue-green-dark/pcbnew ~/.config/kicad/pcbnew` + ## eeschema color-scheme | screenshot From fd975dbb042ee5f1e68935386c1992b96e8a5c3d Mon Sep 17 00:00:00 2001 From: Jan--Henrik Date: Tue, 7 May 2019 20:01:22 +0200 Subject: [PATCH 3/3] fixed: made it less fuzzy --- patch.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/patch.py b/patch.py index 84c3099..6290c5f 100755 --- a/patch.py +++ b/patch.py @@ -6,9 +6,10 @@ orig=open(sys.argv[2],"r") origlines = orig.readlines() for idx,oline in enumerate(origlines): - subst = oline.split('=') + osubst = oline.split('=') for idx1,pline in enumerate(patch): - if subst[0] in pline: + psubst = pline.split('=') + if osubst[0] == psubst[0]: origlines[idx] = pline patch.pop(idx1) origlines += patch