|
26 | 26 | import json |
27 | 27 | import logging |
28 | 28 |
|
| 29 | +from six import string_types |
29 | 30 | from .client import Client, proto, util |
30 | 31 |
|
31 | 32 |
|
@@ -88,7 +89,7 @@ def delete_xpaths(self, xpaths, prefix=None): |
88 | 89 | ------- |
89 | 90 | set() |
90 | 91 | """ |
91 | | - if isinstance(xpaths, str): |
| 92 | + if isinstance(xpaths, string_types): |
92 | 93 | xpaths = [xpaths] |
93 | 94 | paths = [] |
94 | 95 | for xpath in xpaths: |
@@ -128,7 +129,7 @@ def set_json(self, update_json_configs=None, replace_json_configs=None, ietf=Tru |
128 | 129 | raise Exception("Must supply at least one set of configurations to method!") |
129 | 130 |
|
130 | 131 | def check_configs(name, configs): |
131 | | - if isinstance(name, str): |
| 132 | + if isinstance(name, string_types): |
132 | 133 | logging.debug("Handling %s as JSON string.", name) |
133 | 134 | try: |
134 | 135 | configs = json.loads(configs) |
@@ -204,7 +205,7 @@ def get_xpaths(self, xpaths, data_type="ALL", encoding="JSON_IETF"): |
204 | 205 | gnmi_path = None |
205 | 206 | if isinstance(xpaths, (list, set)): |
206 | 207 | gnmi_path = map(util.parse_xpath_to_gnmi_path, set(xpaths)) |
207 | | - elif isinstance(xpaths, str): |
| 208 | + elif isinstance(xpaths, string_types): |
208 | 209 | gnmi_path = [util.parse_xpath_to_gnmi_path(xpaths)] |
209 | 210 | else: |
210 | 211 | raise Exception( |
@@ -279,11 +280,11 @@ def subscribe_xpaths( |
279 | 280 | subscription_list.encoding = util.validate_proto_enum( |
280 | 281 | "encoding", encoding, "Encoding", proto.gnmi_pb2.Encoding |
281 | 282 | ) |
282 | | - if isinstance(xpath_subscriptions, str): |
| 283 | + if isinstance(xpath_subscriptions, string_types): |
283 | 284 | xpath_subscriptions = [xpath_subscriptions] |
284 | 285 | for xpath_subscription in xpath_subscriptions: |
285 | 286 | subscription = None |
286 | | - if isinstance(xpath_subscription, str): |
| 287 | + if isinstance(xpath_subscription, string_types): |
287 | 288 | subscription = proto.gnmi_pb2.Subscription() |
288 | 289 | subscription.path.CopyFrom( |
289 | 290 | util.parse_xpath_to_gnmi_path(xpath_subscription) |
|
0 commit comments