1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/XSLForms/Resources/Common.py Wed Oct 26 00:37:36 2005 +0000
1.3 @@ -0,0 +1,61 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +"""
1.7 +Common resource class functionality.
1.8 +
1.9 +Copyright (C) 2005 Paul Boddie <paul@boddie.org.uk>
1.10 +
1.11 +This library is free software; you can redistribute it and/or
1.12 +modify it under the terms of the GNU Lesser General Public
1.13 +License as published by the Free Software Foundation; either
1.14 +version 2.1 of the License, or (at your option) any later version.
1.15 +
1.16 +This library is distributed in the hope that it will be useful,
1.17 +but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.19 +Lesser General Public License for more details.
1.20 +
1.21 +You should have received a copy of the GNU Lesser General Public
1.22 +License along with this library; if not, write to the Free Software
1.23 +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1.24 +"""
1.25 +
1.26 +import os
1.27 +
1.28 +class CommonResource:
1.29 +
1.30 + "Common resource methods."
1.31 +
1.32 + document_resources = {}
1.33 + resource_dir = None
1.34 +
1.35 + def prepare_document(self, document_identifier):
1.36 +
1.37 + """
1.38 + Prepare a document using the given 'document_identifier'.
1.39 +
1.40 + Return the full path of the document for use either as the source
1.41 + document or as a reference with 'send_output' or 'get_result'.
1.42 + """
1.43 +
1.44 + filename = self.document_resources[document_identifier]
1.45 + return os.path.abspath(os.path.join(self.resource_dir, filename))
1.46 +
1.47 +class PyQtCommonResource(CommonResource):
1.48 +
1.49 + "Common PyQt-compatible resource methods."
1.50 +
1.51 + design_resources = {}
1.52 +
1.53 + def get_document(self, document_identifier):
1.54 + raise NotImplementedError, "get_document"
1.55 +
1.56 + def get_elements(self, document_identifier):
1.57 + doc = self.get_document(document_identifier)
1.58 + return doc.getElementsByTagName(document_identifier + "-enum")
1.59 +
1.60 + def prepare_design(self, design_identifier):
1.61 + filename = self.design_resources[design_identifier]
1.62 + return os.path.abspath(os.path.join(self.resource_dir, filename))
1.63 +
1.64 +# vim: tabstop=4 expandtab shiftwidth=4