|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2007 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Package implementing exporters for various file formats. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtGui import QApplication |
|
11 |
|
12 def getSupportedFormats(): |
|
13 """ |
|
14 Module function to get a dictionary of supported exporters. |
|
15 |
|
16 @return dictionary of supported exporters. The keys are the |
|
17 internal format names. The items are the display strings |
|
18 for the exporters (string) |
|
19 """ |
|
20 supportedFormats = { |
|
21 "HTML" : QApplication.translate('Exporters', "HTML"), |
|
22 "RTF" : QApplication.translate('Exporters', "RTF"), |
|
23 "PDF" : QApplication.translate('Exporters', "PDF"), |
|
24 "TeX" : QApplication.translate('Exporters', "TeX"), |
|
25 } |
|
26 |
|
27 return supportedFormats |
|
28 |
|
29 def getExporter(format, editor): |
|
30 """ |
|
31 Module function to instantiate an exporter object for a given format. |
|
32 |
|
33 @param format format of the exporter (string) |
|
34 @param editor reference to the editor object (QScintilla.Editor.Editor) |
|
35 @return reference to the instanciated exporter object (QScintilla.Exporter.Exporter) |
|
36 """ |
|
37 try: |
|
38 if format == "HTML": |
|
39 from ExporterHTML import ExporterHTML |
|
40 return ExporterHTML(editor) |
|
41 elif format == "PDF": |
|
42 from ExporterPDF import ExporterPDF |
|
43 return ExporterPDF(editor) |
|
44 elif format == "RTF": |
|
45 from ExporterRTF import ExporterRTF |
|
46 return ExporterRTF(editor) |
|
47 elif format == "TeX": |
|
48 from ExporterTEX import ExporterTEX |
|
49 return ExporterTEX(editor) |
|
50 except ImportError: |
|
51 return None |