How to use the dnacentersdk.models.mydict.MyDict function in dnacentersdk

To help you get started, we’ve selected a few dnacentersdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cisco-en-programmability / dnacentersdk / dnacentersdk / models / mydict.py View on Github external
def get(self, key, default=None):
        if key in self:
            return super(MyDict, self).get(key, default)

        else:
            parts = str(key).split('.')
            if len(parts) > 1:
                try:
                    return self.get(parts[0]).get('.'.join(parts[1:]))

                except Exception:
                    return None

            else:
                return super(MyDict, self).get(key, default)
github cisco-en-programmability / dnacentersdk / dnacentersdk / models / mydict.py View on Github external
def _transform(self, source):
        if isinstance(source, (dict, MyDict)):
            return MyDict(source)

        elif isinstance(source, list):
            return [item for item in map(self._transform, source)]

        elif isinstance(source, tuple):
            result = None
            for item in source:

                if not result:
                    result = (self._transform(item),)

                else:
                    result = result + (self._transform(item),)

            return result
github cisco-en-programmability / dnacentersdk / dnacentersdk / models / mydict.py View on Github external
def mydict_data_factory(model, json_data):
    """Data factory function with standard params."""
    # Uses kw (json_data =) to handle array responses.
    # Returns .json_data as is not important.
    return MyDict(json_data=json_data).json_data
github cisco-en-programmability / dnacentersdk / dnacentersdk / models / mydict.py View on Github external
def _get_dict(member):

            if isinstance(member, (dict, MyDict)):
                d = {}
                for k, v in member.items():
                    d[k] = _get_dict(v)

                return d

            elif isinstance(member, (list,)):
                lst = []
                for a in member:
                    lst.append(_get_dict(a))

                return lst

            elif isinstance(member, (tuple,)):
                tpl = tuple()
                for a in member: