Show More
@@ -89,29 +89,31 b' class ExporterNameError(NameError):' | |||
|
89 | 89 | |
|
90 | 90 | |
|
91 | 91 | @DocDecorator |
|
92 |
def export(exporter |
|
|
92 | def export(exporter, nb, **kw): | |
|
93 | 93 | """ |
|
94 | 94 | Export a notebook object using specific exporter class. |
|
95 | 95 | |
|
96 |
exporter |
|
|
97 |
Class type of the exporter that should be used. |
|
|
98 |
|
|
|
99 |
|
|
|
100 | constructor (__init__) with the same signature as the | |
|
101 | base Exporter class.} | |
|
96 | exporter : Exporter class type or instance | |
|
97 | Class type or instance of the exporter that should be used. If the | |
|
98 | method initializes it's own instance of the class, it is ASSUMED that | |
|
99 | the class type provided exposes a constructor (__init__) with the same | |
|
100 | signature as the base Exporter class. | |
|
102 | 101 | """ |
|
103 | 102 | |
|
104 | 103 | #Check arguments |
|
105 |
if exporter |
|
|
104 | if exporter is None: | |
|
106 | 105 | raise TypeError("Exporter is None") |
|
107 |
elif not issubclass(exporter |
|
|
108 |
raise TypeError(" |
|
|
106 | elif not isinstance(exporter, Exporter) and not issubclass(exporter, Exporter): | |
|
107 | raise TypeError("exporter does not inherit from Exporter (base)") | |
|
109 | 108 | if nb is None: |
|
110 | 109 | raise TypeError("nb is None") |
|
111 | 110 | |
|
112 | 111 | #Create the exporter |
|
113 | 112 | resources = kw.pop('resources', None) |
|
114 | exporter_instance = exporter_type(**kw) | |
|
113 | if isinstance(exporter, Exporter): | |
|
114 | exporter_instance = exporter | |
|
115 | else: | |
|
116 | exporter_instance = exporter(**kw) | |
|
115 | 117 | |
|
116 | 118 | #Try to convert the notebook using the appropriate conversion function. |
|
117 | 119 | if isinstance(nb, NotebookNode): |
General Comments 0
You need to be logged in to leave comments.
Login now