From 44ed1a4d1f5209a84f88e3ce38f1a346f5ffd2a9 Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Sun, 2 Jun 2019 11:43:20 +0200 Subject: [PATCH] ensure only one trans_r and one trans_w --- dotdrop/dotfile.py | 4 ++++ tests/test_install.py | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dotdrop/dotfile.py b/dotdrop/dotfile.py index 8c4ab24..7f3f5c3 100644 --- a/dotdrop/dotfile.py +++ b/dotdrop/dotfile.py @@ -42,7 +42,11 @@ class Dotfile(DictParser): self.noempty = noempty self.src = src self.trans_r = trans_r + if trans_r and len(self.trans_r) > 1: + raise Exception('only one trans_read allowed') self.trans_w = trans_w + if trans_w and len(self.trans_w) > 1: + raise Exception('only one trans_write allowed') self.upignore = upignore def get_dotfile_variables(self): diff --git a/tests/test_install.py b/tests/test_install.py index 2c82e45..988ae3a 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -47,8 +47,8 @@ exec bspwm for action in actions: f.write(' {}: {}\n'.format(action.key, action.action)) f.write('trans:\n') - for action in trans: - f.write(' {}: {}\n'.format(action.key, action.action)) + for tr in trans: + f.write(' {}: {}\n'.format(tr.key, tr.action)) f.write('config:\n') f.write(' backup: true\n') f.write(' create: true\n') @@ -64,7 +64,8 @@ exec bspwm for action in d.actions: f.write(' - {}\n'.format(action.key)) if d.trans_r: - f.write(' trans: {}\n'.format(d.trans_r.key)) + for tr in d.trans_r: + f.write(' trans: {}\n'.format(tr.key)) f.write('profiles:\n') f.write(' {}:\n'.format(profile)) f.write(' dotfiles:\n') @@ -165,7 +166,7 @@ exec bspwm tr = Action('testtrans', 'post', cmd) f9, c9 = create_random_file(tmp, content=trans1) dst9 = os.path.join(dst, get_string(6)) - d9 = Dotfile(get_string(6), dst9, os.path.basename(f9), trans_r=tr) + d9 = Dotfile(get_string(6), dst9, os.path.basename(f9), trans_r=[tr]) # to test template f10, _ = create_random_file(tmp, content='{{@@ header() @@}}')