Thanks to visit codestin.com
Credit goes to github.com

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

Commit b8c5e7c

Browse files
Merge pull request #3 from encode/include-util-functions
Include util functions
2 parents 20f67ca + 245c4b1 commit b8c5e7c

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

hal_codec/__init__.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
11
from collections import OrderedDict
2-
from coreapi.codecs.base import BaseCodec, _get_string, _get_dict, _get_bool
3-
from coreapi.compat import force_bytes, urlparse
2+
from coreapi.codecs.base import BaseCodec
3+
from coreapi.compat import force_bytes, string_types, urlparse
44
from coreapi.compat import COMPACT_SEPARATORS, VERBOSE_SEPARATORS
55
from coreapi.document import Document, Link, Array, Object, Field, Error
66
from coreapi.exceptions import ParseError
77
import json
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):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def get_package_data(package):
7171
],
7272
entry_points={
7373
'coreapi.codecs': [
74-
'hal=hal_codec.HALCodec',
74+
'hal=hal_codec:HALCodec',
7575
]
7676
}
7777
)

0 commit comments

Comments
 (0)