silent
[sfa.git] / sfa / client / getRecord.py
index 546e90a..e2be593 100755 (executable)
@@ -7,8 +7,6 @@ Filters/Prints record objects
 faiyaza at cs dot princeton dot edu
 Copyright (c) 2009 Board of Trustees, Princeton University
 
-$Id$
-$HeadURL$
 """
 
 import sys
@@ -16,9 +14,7 @@ import os
 from optparse import OptionParser
 from pprint import pprint
 from xml.parsers.expat import ExpatError
-
-from sfa.util.rspec import RecordSpec
-
+from sfa.util.xml import XML    
 
 def create_parser():
     command = sys.argv[0]
@@ -36,17 +32,17 @@ def create_parser():
     return parser    
 
 
-def printRec(record, filters, options):
+def printRec(record_dict, filters, options):
     line = ""
     if len(filters):
         for filter in filters:
             if options.DEBUG:  print "Filtering on %s" %filter
             line += "%s: %s\n" % (filter, 
-                printVal(record.dict["record"].get(filter, None)))
+                printVal(record_dict.get(filter, None)))
         print line
     else:
         # print the wole thing
-        for (key, value) in record.dict["record"].iteritems():
+        for (key, value) in record_dict.iteritems():
             if (not options.withkey and key in ('gid', 'keys')) or\
                 (not options.plinfo and key == 'pl_info'):
                 continue
@@ -71,16 +67,14 @@ def main():
 
     stdin = sys.stdin.read()
     
-    record = RecordSpec(xml = stdin)
+    record = XML(stdin)
+    record_dict = record.todict()
     
-    if not record.dict.has_key("record"):
-        raise "RecordError", "Input record does not have 'record' tag."
-
     if options.DEBUG: 
-        record.pprint()
+        pprint(record.toxml())
         print "#####################################################"
 
-    printRec(record, args, options)
+    printRec(record_dict, args, options)
 
 if __name__ == '__main__':
     try: main()