Ticket #3532: trac-admin-wiki-import-stdin-4297-trunk.diff
| File trac-admin-wiki-import-stdin-4297-trunk.diff, 1.3 KB (added by sid, 2 years ago) |
|---|
-
trac/admin/console.py
673 673 self._do_wiki_remove(name) 674 674 elif arg[0] == 'import' and len(arg) == 3: 675 675 title = arg[1] 676 file = arg[2]676 file = (len(arg) == 3 and arg[2]) or None 677 677 self._do_wiki_import(file, title) 678 678 elif arg[0] == 'export' and len(arg) in [2,3]: 679 679 page = arg[1] … … 705 705 706 706 def _do_wiki_import(self, filename, title, cursor=None, 707 707 create_only=[]): 708 if not os.path.isfile(filename): 709 raise Exception, '%s is not a file' % filename 708 if not filename: 709 data = to_unicode(sys.stdin.readlines(), 'utf-8') 710 else: 711 if not os.path.isfile(filename): 712 raise Exception, '%s is not a file' % filename 713 f = open(filename,'r') 714 data = to_unicode(f.read(), 'utf-8') 710 715 711 f = open(filename,'r')712 data = to_unicode(f.read(), 'utf-8')713 714 716 # Make sure we don't insert the exact same page twice 715 717 rows = self.db_query("SELECT text FROM wiki WHERE name=%s " 716 718 "ORDER BY version DESC LIMIT 1", cursor,
