1616# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1717# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1818#
19- # $Id: admin.py,v 1.54 2003-05-29 00:42:34 richard Exp $
19+ # $Id: admin.py,v 1.55 2003-06-23 08:05:30 neaj Exp $
2020
2121'''Administration commands for maintaining Roundup trackers.
2222'''
@@ -118,10 +118,10 @@ def usage(self, message=''):
118118 -u -- the user[:password] to use for commands
119119 -d -- print full designators not just class id numbers
120120 -c -- when outputting lists of data, comma-separate them.
121- Same as '-S ","'.
121+ Same as '-S ","'.
122122 -S <string> -- when outputting lists of data, string-separate them
123123 -s -- when outputting lists of data, space-separate them.
124- Same as '-S " "'.
124+ Same as '-S " "'.
125125
126126 Only one of -s, -c or -S can be specified.
127127
@@ -474,44 +474,44 @@ def do_get(self, args):
474474 # get the class
475475 cl = self .get_class (classname )
476476 try :
477- id = []
477+ id = []
478478 if self .separator :
479479 if self .print_designator :
480- # see if property is a link or multilink for
481- # which getting a desginator make sense.
482- # Algorithm: Get the properties of the
483- # current designator's class. (cl.getprops)
484- # get the property object for the property the
485- # user requested (properties[propname])
486- # verify its type (isinstance...)
487- # raise error if not link/multilink
488- # get class name for link/multilink property
489- # do the get on the designators
490- # append the new designators
491- # print
492- properties = cl .getprops ()
493- property = properties [propname ]
494- if not (isinstance (property , hyperdb .Multilink ) or
480+ # see if property is a link or multilink for
481+ # which getting a desginator make sense.
482+ # Algorithm: Get the properties of the
483+ # current designator's class. (cl.getprops)
484+ # get the property object for the property the
485+ # user requested (properties[propname])
486+ # verify its type (isinstance...)
487+ # raise error if not link/multilink
488+ # get class name for link/multilink property
489+ # do the get on the designators
490+ # append the new designators
491+ # print
492+ properties = cl .getprops ()
493+ property = properties [propname ]
494+ if not (isinstance (property , hyperdb .Multilink ) or
495495 isinstance (property , hyperdb .Link )):
496496 raise UsageError , _ ('property %s is not of type Multilink or Link so -d flag does not apply.' )% propname
497497 propclassname = self .db .getclass (property .classname ).classname
498- id = cl .get (nodeid , propname )
499- for i in id :
500- l .append (propclassname + i )
501- else :
502- id = cl .get (nodeid , propname )
498+ id = cl .get (nodeid , propname )
503499 for i in id :
504- l .append (i )
500+ l .append (propclassname + i )
501+ else :
502+ id = cl .get (nodeid , propname )
503+ for i in id :
504+ l .append (i )
505505 else :
506506 if self .print_designator :
507- properties = cl .getprops ()
508- property = properties [propname ]
509- if not (isinstance (property , hyperdb .Multilink ) or
507+ properties = cl .getprops ()
508+ property = properties [propname ]
509+ if not (isinstance (property , hyperdb .Multilink ) or
510510 isinstance (property , hyperdb .Link )):
511511 raise UsageError , _ ('property %s is not of type Multilink or Link so -d flag does not apply.' )% propname
512512 propclassname = self .db .getclass (property .classname ).classname
513- id = cl .get (nodeid , propname )
514- for i in id :
513+ id = cl .get (nodeid , propname )
514+ for i in id :
515515 print propclassname + i
516516 else :
517517 print cl .get (nodeid , propname )
@@ -660,21 +660,21 @@ def do_find(self, args):
660660 designator = []
661661 if self .separator :
662662 if self .print_designator :
663- id = apply (cl .find , (), props )
664- for i in id :
665- designator .append (classname + i )
663+ id = apply (cl .find , (), props )
664+ for i in id :
665+ designator .append (classname + i )
666666 print self .separator .join (designator )
667667 else :
668- print self .separator .join (apply (cl .find , (), props ))
668+ print self .separator .join (apply (cl .find , (), props ))
669669
670670 else :
671671 if self .print_designator :
672- id = apply (cl .find , (), props )
673- for i in id :
674- designator .append (classname + i )
672+ id = apply (cl .find , (), props )
673+ for i in id :
674+ designator .append (classname + i )
675675 print designator
676- else :
677- print apply (cl .find , (), props )
676+ else :
677+ print apply (cl .find , (), props )
678678 except KeyError :
679679 raise UsageError , _ ('%(classname)s has no property '
680680 '"%(propname)s"' )% locals ()
@@ -713,19 +713,19 @@ def do_display(self, args):
713713 raise UsageError , _ ('Not enough arguments supplied' )
714714
715715 # decode the node designator
716- for designator in args [0 ].split (',' ):
716+ for designator in args [0 ].split (',' ):
717717 try :
718718 classname , nodeid = hyperdb .splitDesignator (designator )
719- except hyperdb .DesignatorError , message :
720- raise UsageError , message
719+ except hyperdb .DesignatorError , message :
720+ raise UsageError , message
721721
722- # get the class
723- cl = self .get_class (classname )
722+ # get the class
723+ cl = self .get_class (classname )
724724
725- # display the values
726- for key in cl .properties .keys ():
727- value = cl .get (nodeid , key )
728- print _ ('%(key)s: %(value)s' )% locals ()
725+ # display the values
726+ for key in cl .properties .keys ():
727+ value = cl .get (nodeid , key )
728+ print _ ('%(key)s: %(value)s' )% locals ()
729729
730730 def do_create (self , args , pwre = re .compile (r'{(\w+)}(.+)' )):
731731 '''Usage: create classname property=value ...
@@ -828,12 +828,12 @@ def do_list(self, args):
828828 in order: the key, "name", "title" and then the first property,
829829 alphabetically.
830830
831- With -c, -S or -s print a list of item id's if no property specified.
831+ With -c, -S or -s print a list of item id's if no property specified.
832832 If property specified, print list of that property for every class
833- instance.
833+ instance.
834834 '''
835- if len (args ) > 2 :
836- raise UsageError , _ ('Too many arguments supplied' )
835+ if len (args ) > 2 :
836+ raise UsageError , _ ('Too many arguments supplied' )
837837 if len (args ) < 1 :
838838 raise UsageError , _ ('Not enough arguments supplied' )
839839 classname = args [0 ]
@@ -848,19 +848,19 @@ def do_list(self, args):
848848 propname = cl .labelprop ()
849849
850850 if self .separator :
851- if len (args ) == 2 :
852- # create a list of propnames since user specified propname
853- proplist = []
854- for nodeid in cl .list ():
855- try :
856- proplist .append (cl .get (nodeid , propname ))
857- except KeyError :
858- raise UsageError , _ ('%(classname)s has no property '
859- '"%(propname)s"' )% locals ()
860- print self .separator .join (proplist )
861- else :
862- # create a list of index id's since user didn't specify
863- # otherwise
851+ if len (args ) == 2 :
852+ # create a list of propnames since user specified propname
853+ proplist = []
854+ for nodeid in cl .list ():
855+ try :
856+ proplist .append (cl .get (nodeid , propname ))
857+ except KeyError :
858+ raise UsageError , _ ('%(classname)s has no property '
859+ '"%(propname)s"' )% locals ()
860+ print self .separator .join (proplist )
861+ else :
862+ # create a list of index id's since user didn't specify
863+ # otherwise
864864 print self .separator .join (cl .list ())
865865 else :
866866 for nodeid in cl .list ():
@@ -1391,19 +1391,19 @@ def main(self):
13911391 if opt == '-i' :
13921392 self .tracker_home = arg
13931393 if opt == '-c' :
1394- if self .separator != None :
1395- self .usage ('Only one of -c, -S and -s may be specified' )
1396- return 1
1394+ if self .separator != None :
1395+ self .usage ('Only one of -c, -S and -s may be specified' )
1396+ return 1
13971397 self .separator = ','
13981398 if opt == '-S' :
1399- if self .separator != None :
1400- self .usage ('Only one of -c, -S and -s may be specified' )
1401- return 1
1399+ if self .separator != None :
1400+ self .usage ('Only one of -c, -S and -s may be specified' )
1401+ return 1
14021402 self .separator = arg
1403- if opt == '-s' :
1404- if self .separator != None :
1405- self .usage ('Only one of -c, -S and -s may be specified' )
1406- return 1
1403+ if opt == '-s' :
1404+ if self .separator != None :
1405+ self .usage ('Only one of -c, -S and -s may be specified' )
1406+ return 1
14071407 self .separator = ' '
14081408 if opt == '-d' :
14091409 self .print_designator = 1
0 commit comments