diff env/lib/python3.7/site-packages/schema_salad/utils.py @ 5:9b1c78e6ba9c draft default tip

"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
author shellac
date Mon, 01 Jun 2020 08:59:25 -0400
parents 79f47841a781
children
line wrap: on
line diff
--- a/env/lib/python3.7/site-packages/schema_salad/utils.py	Thu May 14 16:47:39 2020 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-from __future__ import absolute_import
-
-import json
-import os
-from typing import IO, Any, Dict, Mapping, MutableSequence
-
-import six
-
-# move to a regular typing import when Python 3.3-3.6 is no longer supported
-
-
-def add_dictlist(di, key, val):  # type: (Dict[Any, Any], Any, Any) -> None
-    if key not in di:
-        di[key] = []
-    di[key].append(val)
-
-
-def aslist(l):  # type: (Any) -> MutableSequence[Any]
-    """
-    Convenience function to wrap single items and lists.
-
-    Return lists unchanged.
-    """
-
-    if isinstance(l, MutableSequence):
-        return l
-    else:
-        return [l]
-
-
-# http://rightfootin.blogspot.com/2006/09/more-on-python-flatten.html
-
-
-def flatten(l, ltypes=(list, tuple)):
-    # type: (Any, Any) -> Any
-    if l is None:
-        return []
-    if not isinstance(l, ltypes):
-        return [l]
-
-    ltype = type(l)
-    lst = list(l)
-    i = 0
-    while i < len(lst):
-        while isinstance(lst[i], ltypes):
-            if not lst[i]:
-                lst.pop(i)
-                i -= 1
-                break
-            else:
-                lst[i : i + 1] = lst[i]
-        i += 1
-    return ltype(lst)
-
-
-# Check if we are on windows OS
-def onWindows():
-    # type: () -> (bool)
-    return os.name == "nt"
-
-
-def convert_to_dict(j4):  # type: (Any) -> Any
-    if isinstance(j4, Mapping):
-        return {k: convert_to_dict(v) for k, v in j4.items()}
-    elif isinstance(j4, MutableSequence):
-        return [convert_to_dict(v) for v in j4]
-    else:
-        return j4
-
-
-def json_dump(
-    obj,  # type: Any
-    fp,  # type: IO[str]
-    **kwargs  # type: Any
-):  # type: (...) -> None
-    """ Force use of unicode. """
-    if six.PY2:
-        kwargs["encoding"] = "utf-8"
-    json.dump(convert_to_dict(obj), fp, **kwargs)
-
-
-def json_dumps(
-    obj,  # type: Any
-    **kwargs  # type: Any
-):  # type: (...) -> str
-    """ Force use of unicode. """
-    if six.PY2:
-        kwargs["encoding"] = "utf-8"
-    return json.dumps(convert_to_dict(obj), **kwargs)