Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit d08c2ea

Browse files
Include util functions
1 parent 20f67ca commit d08c2ea

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

hal_codec/__init__.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections import OrderedDict
2-
from coreapi.codecs.base import BaseCodec, _get_string, _get_dict, _get_bool
2+
from coreapi.codecs.base import BaseCodec
33
from coreapi.compat import force_bytes, urlparse
44
from coreapi.compat import COMPACT_SEPARATORS, VERBOSE_SEPARATORS
55
from coreapi.document import Document, Link, Array, Object, Field, Error
@@ -8,7 +8,28 @@
88
import uritemplate
99

1010

11-
__version__ = "0.0.2"
11+
__version__ = "0.0.3"
12+
13+
14+
def _get_string(item, key):
15+
value = item.get(key)
16+
if isinstance(value, string_types):
17+
return value
18+
return ''
19+
20+
21+
def _get_dict(item, key):
22+
value = item.get(key)
23+
if isinstance(value, dict):
24+
return value
25+
return {}
26+
27+
28+
def _get_bool(item, key):
29+
value = item.get(key)
30+
if isinstance(value, bool):
31+
return value
32+
return False
1233

1334

1435
def _is_array_containing_instance(value, datatype):

0 commit comments

Comments
 (0)