a little more refactor
This commit is contained in:
17
scam.py
17
scam.py
@ -7,6 +7,7 @@ parser.add_argument("-a", "--all", dest="show_all_settings", action="store_true"
|
|||||||
clargs = parser.parse_args()
|
clargs = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SHOWN_SETTINGS = {
|
SHOWN_SETTINGS = {
|
||||||
"image_background": "Background",
|
"image_background": "Background",
|
||||||
"threshold": "Threshold",
|
"threshold": "Threshold",
|
||||||
@ -21,6 +22,8 @@ ENFORCED_SETTINGS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import itertools
|
||||||
import wx
|
import wx
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -139,7 +142,7 @@ class MainPanel(wx.Panel):
|
|||||||
new_cfg = self.make_cfg()
|
new_cfg = self.make_cfg()
|
||||||
print("\nold config:\n", old_cfg)
|
print("\nold config:\n", old_cfg)
|
||||||
print("\nnew config:\n", new_cfg)
|
print("\nnew config:\n", new_cfg)
|
||||||
print("\nunchanged\n" if old_cfg == new_cfg else "changed")
|
print("\nunchanged\n" if old_cfg == new_cfg else "\nchanged\n")
|
||||||
|
|
||||||
|
|
||||||
def on_save_cfg(self, event):
|
def on_save_cfg(self, event):
|
||||||
@ -179,16 +182,8 @@ def printable(val):
|
|||||||
|
|
||||||
|
|
||||||
def filter_dict(d, *args):
|
def filter_dict(d, *args):
|
||||||
allkeys = []
|
allkeys = itertools.chain.from_iterable(args)
|
||||||
for keys in args:
|
return {k: d.get(k) for k in allkeys}
|
||||||
allkeys.extend(keys)
|
|
||||||
|
|
||||||
res = {k: v for k, v in d.items() if k in allkeys}
|
|
||||||
for k in allkeys:
|
|
||||||
if k not in res:
|
|
||||||
res[k] = None
|
|
||||||
|
|
||||||
return res
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user