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