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