Commits

Jan Guth committed 6122aa1

Writing on function. Switch to workstation.

Comments (0)

Files changed (1)

 #!/usr/bin/env python
 
+__author__ = "Jan Guth a.k.a. prometheus"
+__license__ = "GPLv3"
+__version__ = "0.1"
+__email__ = ""
+__status__ = "Production"
+
 # IMPORT
 
 import urllib.request as url
 parser.add_argument("-v", "--version", help="print verion", required=False)
 args = parser.parse_args()
 
-if args.format == 'xml':
+format = args.format
+
+if format == 'xml':
     format = "xml"
-elif args.format == 'json':
+elif format == 'json':
     format = 'json'
-elif args.format == 'csv':
+elif format == 'csv':
     format = "csv"
 else:
-    print("Invalid exomat.")
+    print("Invalid format.")
  
 ip = args.ip
 
 
 def display():
     '''Displays the results in a humand readable way'''
-    b2s = f.read().decode("utf-8")
-    #print(b2s)
-    
-    print(json.dumps(b2s, sort_keys=True, indent=4))
-        
-display()
+    global format
+    if format == 'xml':
+        b2s = f.read().decode("utf-8")
+    elif format == 'json':
+        print(json.dumps(b2s, sort_keys=True, indent=4))
+    elif format == 'csv':
+        print(b2s)
+   
+display()