X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fclient%2FsetRecord.py;h=405c90d919601f58d525c12d056ff778c78f10db;hb=963704fbb8791685cc5538eeffc8dd7a914e25e6;hp=c3379be5d84d0d3d4fcead12b8cc2c43bbed3912;hpb=34a85fa3d9a21c639208f0cbb0ea74eaf6535118;p=sfa.git diff --git a/sfa/client/setRecord.py b/sfa/client/setRecord.py index c3379be5..405c90d9 100755 --- a/sfa/client/setRecord.py +++ b/sfa/client/setRecord.py @@ -7,17 +7,14 @@ Updates record objects faiyaza at cs dot princeton dot edu Copyright (c) 2009 Board of Trustees, Princeton University -$Id$ -$HeadURL$ """ import sys +sys.path.append('.') import os from optparse import OptionParser from pprint import pprint - -from sfa.util.rspec import RecordSpec - +from sfa.util.xml import XML def create_parser(): command = sys.argv[0] @@ -44,13 +41,13 @@ def editDict(args, recordDict, options): elif vect.count("="): # reassign value - replaceDict({vect.split("=")[0]: returnVal(vect.split("=")[1])}, + replaceDict({vect.split("=")[0]: returnVal("=".join(vect.split("=")[1:]))}, recordDict, options) else: - if vect in recordDict: - del recordDict[vect] - else: - raise TypeError, "Argument error: Records are updated with \n" \ + if vect in recordDict: + del recordDict[vect] + else: + raise TypeError, "Argument error: Records are updated with \n" \ "key=val1,val2,valN or\n" \ "key+=val1,val2,valN \n%s Unknown key/val" % vect @@ -93,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)