diff --git a/modules/websubmit/lib/bibdocfilecli.py b/modules/websubmit/lib/bibdocfilecli.py index bf5af3ff1..7548fa1b7 100644 --- a/modules/websubmit/lib/bibdocfilecli.py +++ b/modules/websubmit/lib/bibdocfilecli.py @@ -1,509 +1,511 @@ # -*- coding: utf-8 -*- ## ## $Id$ ## ## This file is part of CDS Invenio. ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN. ## ## CDS Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## CDS Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with CDS Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. """ BibDocAdmin CLI administration tool """ __revision__ = "$Id$" import sys import os import time from optparse import OptionParser, OptionGroup from tempfile import mkstemp from invenio.config import CFG_TMPDIR from invenio.bibdocfile import BibRecDocs, BibDoc, InvenioWebSubmitFileError, \ nice_size, check_valid_url, clean_url, get_docname_from_url, \ get_format_from_url, KEEP_OLD_VALUE from invenio.intbitset import intbitset from invenio.search_engine import perform_request_search from invenio.textutils import wrap_text_in_a_box, wait_for_user from invenio.dbquery import run_sql from invenio.bibtask import task_low_level_submission from invenio.bibrecord import encode_for_xml def _xml_mksubfield(key, subfield, fft): return fft.get(key, None) and '\t\t%s\n' % (subfield, encode_for_xml(fft[key])) or '' def _xml_fft_creator(fft): """Transform an fft dictionary (made by keys url, docname, format, new_docname, icon, comment, description, restriction, doctype, into an xml string.""" - out = '\t\n' + out = '\t\n' out += _xml_mksubfield('url', 'a', fft) out += _xml_mksubfield('docname', 'n', fft) out += _xml_mksubfield('format', 'f', fft) out += _xml_mksubfield('newdocname', 'm', fft) out += _xml_mksubfield('doctype', 't', fft) out += _xml_mksubfield('description', 'd', fft) out += _xml_mksubfield('comment', 'c', fft) out += _xml_mksubfield('restriction', 'r', fft) out += _xml_mksubfield('icon', 'x', fft) out += '\t\n' return out def ffts_to_xml(ffts): """Transform a dictionary: recid -> ffts where ffts is a list of fft dictionary into xml. """ out = '' for recid, ffts in ffts.iteritems(): + out += '\n' + out += '\t%i\n' % recid if ffts: - out += '\n' - out += '\t%i\n' % recid for fft in ffts: out += _xml_fft_creator(fft) - out += '\n' + else: + out += '\n' + out += '\n' return out def get_usage(): """Return a nicely formatted string for printing the help of bibdocadmin""" return """usage: %prog [options] : --pattern , --collection , --recid , --recid2 , --docid , --all --docid2 , --docname , : --get-info, --get-stats, --get-usage, --get-docnames --get-docids, --get-recids, --get-doctypes, --get-revisions, --get-last-revisions, --get-formats, --get-comments, --get-descriptions, --get-restrictions, --get-icons, --get-history, --delete, --undelete, --purge, --expunge, --revert , --check-md5, --update-md5, --set-doctype , --set-docname , --set-comment , --set-description , --set-restriction , --set-icon , --append , --revise , [options]: --with-stamp-template