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@600 | 8 | This program is free software; you can redistribute it and/or modify it under |
paulb@600 | 9 | the terms of the GNU Lesser General Public License as published by the Free |
paulb@600 | 10 | Software Foundation; either version 3 of the License, or (at your option) any |
paulb@600 | 11 | later version. |
paulb@354 | 12 | |
paulb@600 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT |
paulb@600 | 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paulb@600 | 15 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
paulb@600 | 16 | details. |
paulb@354 | 17 | |
paulb@600 | 18 | You should have received a copy of the GNU Lesser General Public License along |
paulb@600 | 19 | with this program. If not, see <http://www.gnu.org/licenses/>. |
paulb@354 | 20 | """ |
paulb@354 | 21 | |
paulb@354 | 22 | import os |
paulb@354 | 23 | |
paulb@354 | 24 | class CommonResource: |
paulb@354 | 25 | |
paulb@354 | 26 | "Common resource methods." |
paulb@354 | 27 | |
paulb@354 | 28 | document_resources = {} |
paulb@354 | 29 | resource_dir = None |
paulb@354 | 30 | |
paulb@354 | 31 | def prepare_document(self, document_identifier): |
paulb@354 | 32 | |
paulb@354 | 33 | """ |
paulb@354 | 34 | Prepare a document using the given 'document_identifier'. |
paulb@354 | 35 | |
paulb@354 | 36 | Return the full path of the document for use either as the source |
paulb@354 | 37 | document or as a reference with 'send_output' or 'get_result'. |
paulb@354 | 38 | """ |
paulb@354 | 39 | |
paulb@354 | 40 | filename = self.document_resources[document_identifier] |
paulb@354 | 41 | return os.path.abspath(os.path.join(self.resource_dir, filename)) |
paulb@354 | 42 | |
paulb@354 | 43 | # vim: tabstop=4 expandtab shiftwidth=4 |