comparison roundup-admin @ 167:a49c8a2ddd26

Added time logging and file uploading to the templates.
author Richard Jones <richard@users.sourceforge.net>
date Mon, 30 Jul 2001 08:12:17 +0000
parents 002249ffa5d0
children 996eaf90c01e
comparison
equal deleted inserted replaced
166:d469fb3beda1 167:a49c8a2ddd26
1 #! /usr/bin/python 1 #! /usr/bin/python
2 # $Id: roundup-admin,v 1.9 2001-07-30 03:52:55 richard Exp $ 2 # $Id: roundup-admin,v 1.10 2001-07-30 08:12:17 richard Exp $
3 3
4 import sys 4 import sys
5 if int(sys.version[0]) < 2: 5 if int(sys.version[0]) < 2:
6 print 'Roundup requires python 2.0 or later.' 6 print 'Roundup requires python 2.0 or later.'
7 sys.exit(1) 7 sys.exit(1)
8 8
9 import string, os, getpass, getopt 9 import string, os, getpass, getopt, re
10 from roundup import date, roundupdb, init 10 from roundup import date, roundupdb, init
11 11
12 def usage(message=''): 12 def usage(message=''):
13 if message: message = 'Problem: '+message+'\n' 13 if message: message = 'Problem: '+message+'\n'
14 commands = [] 14 commands = []
171 171
172 def do_find(db, args): 172 def do_find(db, args):
173 '''Usage: find classname propname=value ... 173 '''Usage: find classname propname=value ...
174 Find the nodes of the given class with a given property value. 174 Find the nodes of the given class with a given property value.
175 175
176 Find the nodes of the given class with a given property value. 176 Find the nodes of the given class with a given property value. The
177 value may be either the nodeid of the linked node, or its key value.
177 ''' 178 '''
178 classname = args[0] 179 classname = args[0]
179 cl = db.getclass(classname) 180 cl = db.getclass(classname)
180 181
181 # look up the linked-to class and get the nodeid that has the value 182 # look up the linked-to class and get the nodeid that has the value
182 propname, value = args[1:].split('=') 183 propname, value = args[1].split('=')
183 propcl = cl[propname].classname 184 num_re = re.compile('^\d+$')
184 nodeid = propcl.lookup(value) 185 if num_re.match(value):
186 nodeid = value
187 else:
188 propcl = cl.properties[propname].classname
189 propcl = db.getclass(propcl)
190 nodeid = propcl.lookup(value)
185 191
186 # now do the find 192 # now do the find
187 # TODO: handle the -c option 193 # TODO: handle the -c option
188 print cl.find(propname, nodeid) 194 print cl.find(**{propname: nodeid})
189 return 0 195 return 0
190 196
191 def do_spec(db, args): 197 def do_spec(db, args):
192 '''Usage: spec classname 198 '''Usage: spec classname
193 Show the properties for a classname. 199 Show the properties for a classname.
234 Lists all instances of the given class along. If the property is not 240 Lists all instances of the given class along. If the property is not
235 specified, the "label" property is used. The label property is tried 241 specified, the "label" property is used. The label property is tried
236 in order: the key, "name", "title" and then the first property, 242 in order: the key, "name", "title" and then the first property,
237 alphabetically. 243 alphabetically.
238 ''' 244 '''
239 db = instance.open()
240 classname = args[0] 245 classname = args[0]
241 cl = db.getclass(classname) 246 cl = db.getclass(classname)
242 if len(args) > 1: 247 if len(args) > 1:
243 key = args[1] 248 key = args[1]
244 else: 249 else:
402 if __name__ == '__main__': 407 if __name__ == '__main__':
403 sys.exit(main()) 408 sys.exit(main())
404 409
405 # 410 #
406 # $Log: not supported by cvs2svn $ 411 # $Log: not supported by cvs2svn $
412 # Revision 1.9 2001/07/30 03:52:55 richard
413 # init help now lists templates and backends
414 #
407 # Revision 1.8 2001/07/30 02:37:07 richard 415 # Revision 1.8 2001/07/30 02:37:07 richard
408 # Freshen is really broken. Commented out. 416 # Freshen is really broken. Commented out.
409 # 417 #
410 # Revision 1.7 2001/07/30 01:28:46 richard 418 # Revision 1.7 2001/07/30 01:28:46 richard
411 # Bugfixes 419 # Bugfixes

Roundup Issue Tracker: http://roundup-tracker.org/