X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fclient%2FsetRecord.py;h=405c90d919601f58d525c12d056ff778c78f10db;hb=c93d4d0631f5a295d209c6cb6f40ead6e2e97913;hp=0d7dd16dc97278eee4ada79f39855f859c43dd2e;hpb=f13173726f8382eef380f1e754f24dd2b126a77b;p=sfa.git diff --git a/sfa/client/setRecord.py b/sfa/client/setRecord.py index 0d7dd16d..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,10 +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: - 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 @@ -90,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)