1 #!/usr/bin/env python 2 3 """ 4 Common resource class functionality. 5 6 Copyright (C) 2005 Paul Boddie <paul@boddie.org.uk> 7 8 This library is free software; you can redistribute it and/or 9 modify it under the terms of the GNU Lesser General Public 10 License as published by the Free Software Foundation; either 11 version 2.1 of the License, or (at your option) any later version. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with this library; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 """ 22 23 import os 24 25 class CommonResource: 26 27 "Common resource methods." 28 29 document_resources = {} 30 resource_dir = None 31 32 def prepare_document(self, document_identifier): 33 34 """ 35 Prepare a document using the given 'document_identifier'. 36 37 Return the full path of the document for use either as the source 38 document or as a reference with 'send_output' or 'get_result'. 39 """ 40 41 filename = self.document_resources[document_identifier] 42 return os.path.abspath(os.path.join(self.resource_dir, filename)) 43 44 # vim: tabstop=4 expandtab shiftwidth=4