Merge pull request #6 from Jan--Henrik/master

Automatic patching
This commit is contained in:
Thomas Pointhuber 2019-05-09 11:03:27 +02:00 committed by GitHub
commit 86d84cc2af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View file

@ -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 <patch file> <config file>`
For example:
`python3.6 patch.py ~/kicad-color-schemes/blue-green-dark/pcbnew ~/.config/kicad/pcbnew`
## eeschema
color-scheme | screenshot

20
patch.py Executable file
View file

@ -0,0 +1,20 @@
#!/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):
osubst = oline.split('=')
for idx1,pline in enumerate(patch):
psubst = pline.split('=')
if osubst[0] == psubst[0]:
origlines[idx] = pline
patch.pop(idx1)
origlines += patch
orig.close
new=open(sys.argv[2],"w")
new.writelines(origlines)
new.close