From d97f1a4f4bee8dd242b83f263d39c99323b3081b Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Fri, 21 Oct 2011 15:50:37 -0400 Subject: [PATCH] use sfa.util.xml.XML instead of sfa.util.rspec.RecordSpec --- sfa/client/getRecord.py | 17 ++++++++--------- sfa/client/setRecord.py | 14 +++++++------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/sfa/client/getRecord.py b/sfa/client/getRecord.py index 92937806..e2be593b 100755 --- a/sfa/client/getRecord.py +++ b/sfa/client/getRecord.py @@ -14,6 +14,7 @@ import os from optparse import OptionParser from pprint import pprint from xml.parsers.expat import ExpatError +from sfa.util.xml import XML def create_parser(): command = sys.argv[0] @@ -31,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 @@ -66,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() diff --git a/sfa/client/setRecord.py b/sfa/client/setRecord.py index 4cd22a4e..405c90d9 100755 --- a/sfa/client/setRecord.py +++ b/sfa/client/setRecord.py @@ -14,6 +14,7 @@ sys.path.append('.') import os from optparse import OptionParser from pprint import pprint +from sfa.util.xml import XML def create_parser(): command = sys.argv[0] @@ -89,15 +90,14 @@ def main(): parser = create_parser(); (options, args) = parser.parse_args() - record = RecordSpec(xml = sys.stdin.read()) - + record = XML(sys.stdin.read()) + record_dict = record.todict() if args: - editDict(args, record.dict["record"], options) + editDict(args, record_dict, options) if options.DEBUG: - print "New Record:\n%s" % record.dict - record.pprint() - - record.parseDict(record.dict) + print "New Record:\n%s" % record_dict + + record.parse_dict(record_dict) s = record.toxml() sys.stdout.write(s) -- 2.47.0