aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/utility.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-07-21 16:33:28 -0400
committerW. Trevor King <wking@drexel.edu>2009-07-21 16:33:28 -0400
commit885b04b50ad3bbde81ec2eccfbfb2e516d0d3a80 (patch)
tree794458babd1aa824b3e343291f6c5f2d7704f27f /libbe/utility.py
parent19fc927cf959005a71813ca702fc6c1aa28d3a92 (diff)
parent86d74730ded314d960e0465f2eb50e5fb66c4767 (diff)
downloadbugseverywhere-885b04b50ad3bbde81ec2eccfbfb2e516d0d3a80.tar.gz
Merged assorted changes from be.wtk-rr for BugDir.extra_strings.
Other highlights: * be show --no-comments * Improved *.sync_with_disk. * Improved be-mbox-to-xml.
Diffstat (limited to 'libbe/utility.py')
-rw-r--r--libbe/utility.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/libbe/utility.py b/libbe/utility.py
index f27d7eb..3df06b4 100644
--- a/libbe/utility.py
+++ b/libbe/utility.py
@@ -23,7 +23,6 @@ import time
import types
import doctest
-
def search_parent_directories(path, filename):
"""
Find the file (or directory) named filename in path or in any
@@ -106,5 +105,25 @@ def time_to_gmtime(str_time):
time_val = str_to_time(str_time)
return time_to_str(time_val)
+def iterable_full_of_strings(value, alternative=None):
+ """
+ Require an iterable full of strings.
+ >>> iterable_full_of_strings([])
+ True
+ >>> iterable_full_of_strings(["abc", "def", u"hij"])
+ True
+ >>> iterable_full_of_strings(["abc", None, u"hij"])
+ False
+ >>> iterable_full_of_strings(None, alternative=None)
+ True
+ """
+ if value == alternative:
+ return True
+ elif not hasattr(value, "__iter__"):
+ return False
+ for x in value:
+ if type(x) not in types.StringTypes:
+ return False
+ return True
suite = doctest.DocTestSuite()