diff --git a/roundup/admin.py b/roundup/admin.py
index e89f8643df326727cf15b1142a8be69d564fa09b..6c3502e5062b61a93fc2da9ed140c5c3bfb676ba 100644 (file)
--- a/roundup/admin.py
+++ b/roundup/admin.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: admin.py,v 1.63 2004-03-21 23:39:08 richard Exp $
+# $Id: admin.py,v 1.64 2004-04-02 05:58:43 richard Exp $
'''Administration commands for maintaining Roundup trackers.
'''
# do all the classes specified
for classname in classes:
cl = self.get_class(classname)
+
f = open(os.path.join(dir, classname+'.csv'), 'w')
writer = rcsv.writer(f, rcsv.colon_separated)
+
properties = cl.getprops()
propnames = properties.keys()
propnames.sort()
fields.append('is retired')
writer.writerow(fields)
- # all nodes for this class (not using list() 'cos it doesn't
- # include retired nodes)
-
- for nodeid in self.db.getclass(classname).getnodeids():
- # get the regular props
- writer.writerow (cl.export_list(propnames, nodeid))
+ # all nodes for this class
+ for nodeid in cl.getnodeids():
+ writer.writerow(cl.export_list(propnames, nodeid))
# close this file
f.close()
+
+ # export the journals
+ jf = open(os.path.join(dir, classname+'-journals.csv'), 'w')
+ journals = rcsv.writer(jf, rcsv.colon_separated)
+ map(journals.writerow, cl.export_journals())
+ jf.close()
return 0
def do_import(self, args):
Import a database from the directory containing CSV files, one per
class to import.
- The files must define the same properties as the class (including having
- a "header" line with those property names.)
+ The files must define the same properties as the class (including
+ having a "header" line with those property names.)
The imported nodes will have the same nodeid as defined in the
import file, thus replacing any existing content.
from roundup import hyperdb
for file in os.listdir(args[0]):
+ classname, ext = os.path.splitext(file)
# we only care about CSV files
- if not file.endswith('.csv'):
+ if ext != '.csv' or classname.endswith('-journals'):
continue
- f = open(os.path.join(args[0], file))
-
- # get the classname
- classname = os.path.splitext(file)[0]
+ cl = self.get_class(classname)
# ensure that the properties and the CSV file headings match
- cl = self.get_class(classname)
+ f = open(os.path.join(args[0], file))
reader = rcsv.reader(f, rcsv.colon_separated)
file_props = None
maxid = 1
-
# loop through the file and create a node for each entry
for r in reader:
if file_props is None:
file_props = r
continue
-
# do the import and figure the current highest nodeid
maxid = max(maxid, int(cl.import_list(file_props, r)))
+ f.close()
+
+ # import the journals
+ f = open(os.path.join(args[0], classname + '-journals.csv'))
+ reader = rcsv.reader(f, rcsv.colon_separated)
+ cl.import_journals(reader)
+ f.close()
# set the id counter
print 'setting', classname, maxid+1
self.db.setid(classname, str(maxid+1))
+
return 0
def do_pack(self, args):