#!/usr/bin/env python2.7

# Copyright 2015 Cisco Systems, Inc.
# 
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# 
# http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

''' Sample usage of function 'topology'.

    Print the function's documentation.
    Apply the function to the network.
    Print the function output.
'''

from __future__ import print_function as _print_function
from basics.interpreter import sys_exit
from basics.topology import topology
import os

def main():
    '''
    This sample script does:
    http://127.0.0.1:8181/restconf/operational/network-topology:network-topology/topology/topology-netconf
    which is not found (404) in ODL Helium.
    It might work in ODL Lithium.
    
    The request for the Yang container *does* succeed:
    http://127.0.0.1:8181/restconf/operational/network-topology:network-topology
    '''
    try:
        print(topology("operational"))
        return os.EX_OK
    except Exception as e:
        print(e)
        return os.EX_SOFTWARE

if __name__ == "__main__":
    sys_exit(main())


@@ -887,16 +887,76 @@
 opology%0A
+from pydoc import plain%0Afrom pydoc import render_doc as doc%0A
 import o
@@ -1337,24 +1337,56 @@
 ogy%0A    '''%0A
+    print(plain(doc(topology)))%0A
     try:%0A   

print help fn