Skip to content

Commit 4a2e3e7

Browse files
committed
Add importtables roundup-admin command.
I am surprised this doesn't exist. It's the dual of exporttables. Output of exporttables can't be imported by import, so I am not sure why it's useful. I can't find the sourceforge ticket that is referenced in the creation of exporttables. I considered trapping the error generated when import can't find file content, but that's not a great idea as it can mask an invalid/incorrect export and the loss of data associated with it.
1 parent 090754b commit 4a2e3e7

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ Features:
5555
- New parameter @stats for REST interface that provides the same
5656
performance stats as the web interface's CGI_SHOW_TIMING env
5757
variable. (John Rouillard)
58+
- New roundup-admin command importtables allows importing just the
59+
database dump created by exporttables. (John Rouillard)
5860

5961
2020-04-05 2.0.0 beta 0
6062

roundup/admin.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ def do_exporttables(self, args):
13451345
"""
13461346
return self.do_export(args, export_files=False)
13471347

1348-
def do_import(self, args):
1348+
def do_import(self, args, import_files=True):
13491349
''"""Usage: import import_dir
13501350
Import a database from the directory containing CSV files,
13511351
two per class to import.
@@ -1403,7 +1403,7 @@ class colon_separated(csv.excel):
14031403

14041404
# do the import and figure the current highest nodeid
14051405
nodeid = cl.import_list(file_props, r)
1406-
if hasattr(cl, 'import_files'):
1406+
if hasattr(cl, 'import_files') and import_files:
14071407
cl.import_files(dir, nodeid)
14081408
maxid = max(maxid, int(nodeid))
14091409

@@ -1427,6 +1427,13 @@ class colon_separated(csv.excel):
14271427
self.db_uncommitted = True
14281428
return 0
14291429

1430+
def do_importtables(self, args):
1431+
''"""Usage: importtables export_dir
1432+
1433+
This imports the database tables exported using exporttables.
1434+
"""
1435+
return self.do_import(args, import_files=False)
1436+
14301437
def do_pack(self, args):
14311438
''"""Usage: pack period | date
14321439

0 commit comments

Comments
 (0)