comparison roundup/admin.py @ 2499:4d112730e02f maint-0.7

merge from HEAD
author Richard Jones <richard@users.sourceforge.net>
date Thu, 24 Jun 2004 07:14:49 +0000
parents 164b704c8f98
children 3550ad56137a
comparison
equal deleted inserted replaced
2495:8ff455218ec2 2499:4d112730e02f
14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
18 # 18 #
19 # $Id: admin.py,v 1.68.2.2 2004-06-23 22:59:17 richard Exp $ 19 # $Id: admin.py,v 1.68.2.3 2004-06-24 07:14:22 richard Exp $
20 20
21 '''Administration commands for maintaining Roundup trackers. 21 '''Administration commands for maintaining Roundup trackers.
22 ''' 22 '''
23 __docformat__ = 'restructuredtext' 23 __docformat__ = 'restructuredtext'
24 24
1029 1029
1030 f = open(os.path.join(dir, classname+'.csv'), 'w') 1030 f = open(os.path.join(dir, classname+'.csv'), 'w')
1031 writer = rcsv.writer(f, rcsv.colon_separated) 1031 writer = rcsv.writer(f, rcsv.colon_separated)
1032 1032
1033 properties = cl.getprops() 1033 properties = cl.getprops()
1034 propnames = properties.keys() 1034 propnames = cl.export_propnames()
1035 propnames.sort()
1036 fields = propnames[:] 1035 fields = propnames[:]
1037 fields.append('is retired') 1036 fields.append('is retired')
1038 writer.writerow(fields) 1037 writer.writerow(fields)
1039 1038
1040 # all nodes for this class 1039 # all nodes for this class
1041 for nodeid in cl.getnodeids(): 1040 for nodeid in cl.getnodeids():
1042 writer.writerow(cl.export_list(propnames, nodeid)) 1041 writer.writerow(cl.export_list(propnames, nodeid))
1042 if hasattr(cl, 'export_files'):
1043 cl.export_files(dir, nodeid)
1043 1044
1044 # close this file 1045 # close this file
1045 f.close() 1046 f.close()
1046 1047
1047 # export the journals 1048 # export the journals
1075 raise UsageError, _('Not enough arguments supplied') 1076 raise UsageError, _('Not enough arguments supplied')
1076 if rcsv.error: 1077 if rcsv.error:
1077 raise UsageError, _(rcsv.error) 1078 raise UsageError, _(rcsv.error)
1078 from roundup import hyperdb 1079 from roundup import hyperdb
1079 1080
1080 for file in os.listdir(args[0]): 1081 # directory to import from
1082 dir = args[0]
1083
1084 # import all the files
1085 for file in os.listdir(dir):
1081 classname, ext = os.path.splitext(file) 1086 classname, ext = os.path.splitext(file)
1082 # we only care about CSV files 1087 # we only care about CSV files
1083 if ext != '.csv' or classname.endswith('-journals'): 1088 if ext != '.csv' or classname.endswith('-journals'):
1084 continue 1089 continue
1085 1090
1086 cl = self.get_class(classname) 1091 cl = self.get_class(classname)
1087 1092
1088 # ensure that the properties and the CSV file headings match 1093 # ensure that the properties and the CSV file headings match
1089 f = open(os.path.join(args[0], file)) 1094 f = open(os.path.join(dir, file))
1090 reader = rcsv.reader(f, rcsv.colon_separated) 1095 reader = rcsv.reader(f, rcsv.colon_separated)
1091 file_props = None 1096 file_props = None
1092 maxid = 1 1097 maxid = 1
1093 # loop through the file and create a node for each entry 1098 # loop through the file and create a node for each entry
1094 for r in reader: 1099 for r in reader:
1095 if file_props is None: 1100 if file_props is None:
1096 file_props = r 1101 file_props = r
1097 continue 1102 continue
1098 # do the import and figure the current highest nodeid 1103 # do the import and figure the current highest nodeid
1099 maxid = max(maxid, int(cl.import_list(file_props, r))) 1104 nodeid = int(cl.import_list(file_props, r))
1105 if hasattr(cl, 'import_files'):
1106 cl.import_files(dir, nodeid)
1107 maxid = max(maxid, nodeid)
1108
1100 f.close() 1109 f.close()
1101 1110
1102 # import the journals 1111 # import the journals
1103 f = open(os.path.join(args[0], classname + '-journals.csv')) 1112 f = open(os.path.join(args[0], classname + '-journals.csv'))
1104 reader = rcsv.reader(f, rcsv.colon_separated) 1113 reader = rcsv.reader(f, rcsv.colon_separated)

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