How to use the pyats.tcl.cast_list function in pyats

To help you get started, we’ve selected a few pyats 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 CiscoTestAutomation / genieparser / src / genie / libs / parser / base.py View on Github external
def tcl_package_require_caas():
    if 'XBU_SHARED' in os.environ \
            and os.environ['XBU_SHARED'] not in \
            tcl.cast_list(tcl.get_var('::auto_path'), item_cast=tclstr):
        tcl.call('lappend', '::auto_path', os.environ['XBU_SHARED'])
    tcl.call('package', 'require', 'cAAs')
github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / topology_mapper / cli.py View on Github external
def _clean_cli(clie):
                clie = pyats.tcl.cast_list(clie)
                if len(clie) == 2:
                    return (clie[0], tuple(
                        (_clean_cli(e) for e in pyats.tcl.cast_list(clie[1]))))
                else:
                    return (clie[0], None)
github CiscoTestAutomation / genieparser / src / genie / libs / parser / base.py View on Github external
def tcl_invoke_ats_cmd(cmd, *, cast_=None, **kwargs):

    cmd = TclCommand(cmd, keywords=kwargs, cast=tcl.cast_list)
    result = cmd()
    result_code = result[0]
    result_msg = result[1] if len(result) == 2 else result[1:]
    try:
        result_code = tcl.cast_int(result[0])
    except ValueError:
        result_code = tclstr(result[0])
    if result_code in ('passed', 1):
        if cast_:
            result_msg = cast_(result_msg)
        return result_msg
    else:
        raise RuntimeError(tclstr(result_msg))
github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / topology_mapper / cli.py View on Github external
def _clean_cli(clie):
                clie = pyats.tcl.cast_list(clie)
                if len(clie) == 2:
                    return (clie[0], tuple(sorted(
                        (_clean_cli(e) for e in pyats.tcl.cast_list(clie[1])),
                        key=functools.cmp_to_key(_DictionaryCompare_index0))))
                else:
                    return (clie[0], None)
github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / topology_mapper / cli.py View on Github external
def _clean_cli(clie):
                clie = pyats.tcl.cast_list(clie)
                if len(clie) == 2:
                    return (clie[0], tuple(sorted(
                        (_clean_cli(e) for e in pyats.tcl.cast_list(clie[1])),
                        key=functools.cmp_to_key(_DictionaryCompare_index0))))
                else:
                    return (clie[0], None)
github CiscoTestAutomation / genielibs / pkgs / conf-pkg / src / genie / libs / conf / topology_mapper / cli.py View on Github external
tree = tuple(sorted(
                (_clean_cli(e) for e in pyats.tcl.cast_list(cli)),
                key=functools.cmp_to_key(_DictionaryCompare_index0)))
        else:

            def _clean_cli(clie):
                clie = pyats.tcl.cast_list(clie)
                if len(clie) == 2:
                    return (clie[0], tuple(
                        (_clean_cli(e) for e in pyats.tcl.cast_list(clie[1]))))
                else:
                    return (clie[0], None)

            tree = tuple(
                (_clean_cli(e) for e in pyats.tcl.cast_list(cli)))

        return tree

    else:

        is_nxos = os == 'nxos'

        lvl = 0
        lvl_indent = {
            lvl: 0,
        }
        lvl_tree = {
            lvl: [],
        }

        def _wrap_up_one_lvl():