More Python 3 fixes, mostly about string/byte/unicode handling.
[h5config.git] / h5config / storage / __init__.py
index 00d6ccade0817ea7a7e0a9069a05b860d6898bd6..48028d4bc0388c64e57d21d67d58d266decbc97d 100644 (file)
@@ -17,6 +17,8 @@
 
 import os as _os
 import os.path as _os_path
+import sys as _sys
+import types as _types
 
 
 class Storage (object):
@@ -54,3 +56,10 @@ class FileStorage (Storage):
         dirname = _os_path.dirname(filename)
         if dirname and not _os_path.isdir(dirname):
             _os.makedirs(dirname)
+
+
+def is_string(x):
+    if _sys.version_info >= (3,):
+        return isinstance(x, (bytes, str))
+    else:  # Python 2 compatibility
+        return isinstance(x, _types.StringTypes)