From 49bdd83ea1191bf684c3e680b65cf9080d65cb81 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Sat, 21 Dec 2013 22:00:57 +0100 Subject: [PATCH] test for feature instead of type Signed-off-by: Steven Armstrong --- cdist/util/fsproperty.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cdist/util/fsproperty.py b/cdist/util/fsproperty.py index 5814b2b4..797c929b 100644 --- a/cdist/util/fsproperty.py +++ b/cdist/util/fsproperty.py @@ -134,7 +134,11 @@ class DirectoryDict(collections.MutableMapping): def __setitem__(self, key, value): try: with open(os.path.join(self.path, key), "w") as fd: - if type(value) == type([]): + if (not hasattr(value, 'strip') and + hasattr(value, '__getitem__') or + hasattr(value, '__iter__')): + # if it looks like a sequence and quacks like a sequence, + # it is a sequence for v in value: fd.write(str(v) + '\n') else: