From dac9abc52674721731f50ea0c5a72e43a43f3966 Mon Sep 17 00:00:00 2001 From: Ruud Date: Sun, 15 Apr 2012 10:44:21 +0200 Subject: [PATCH] Remove duplicates on list merge --- couchpotato/core/helpers/variable.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/couchpotato/core/helpers/variable.py b/couchpotato/core/helpers/variable.py index f38cf39c..53b71941 100644 --- a/couchpotato/core/helpers/variable.py +++ b/couchpotato/core/helpers/variable.py @@ -36,10 +36,18 @@ def mergeDicts(a, b): stack.append((current_dst[key], current_src[key])) elif isinstance(current_src[key], list) and isinstance(current_dst[key], list): current_dst[key].extend(current_src[key]) + current_dst[key] = removeListDuplicates(current_dst[key]) else: current_dst[key] = current_src[key] return dst +def removeListDuplicates(seq): + checked = [] + for e in seq: + if e not in checked: + checked.append(e) + return checked + def flattenList(l): if isinstance(l, list): return sum(map(flattenList, l))