Show More
@@ -69,6 +69,7 b' def coalesce_streams(cell, resources, index):' | |||||
69 | last.text += output.text |
|
69 | last.text += output.text | |
70 | else: |
|
70 | else: | |
71 | new_outputs.append(output) |
|
71 | new_outputs.append(output) | |
|
72 | last = output | |||
72 |
|
73 | |||
73 | cell.outputs = new_outputs |
|
74 | cell.outputs = new_outputs | |
74 | return cell, resources |
|
75 | return cell, resources |
@@ -56,7 +56,7 b' class CSSHTMLHeaderTransformer(Transformer):' | |||||
56 | self._regen_header() |
|
56 | self._regen_header() | |
57 |
|
57 | |||
58 |
|
58 | |||
59 |
def |
|
59 | def call(self, nb, resources): | |
60 | """Fetch and add CSS to the resource dictionary |
|
60 | """Fetch and add CSS to the resource dictionary | |
61 |
|
61 | |||
62 | Fetch CSS from IPython and Pygments to add at the beginning |
|
62 | Fetch CSS from IPython and Pygments to add at the beginning |
@@ -31,7 +31,7 b' class ExtractOutputTransformer(Transformer):' | |||||
31 | outputs are returned in the 'resources' dictionary. |
|
31 | outputs are returned in the 'resources' dictionary. | |
32 | """ |
|
32 | """ | |
33 |
|
33 | |||
34 |
|
|
34 | output_filename_template = Unicode( | |
35 | "{unique_key}_{cell_index}_{index}.{extension}", config=True) |
|
35 | "{unique_key}_{cell_index}_{index}.{extension}", config=True) | |
36 |
|
36 | |||
37 |
|
37 | |||
@@ -51,9 +51,9 b' class ExtractOutputTransformer(Transformer):' | |||||
51 | """ |
|
51 | """ | |
52 |
|
52 | |||
53 | #Get the unique key from the resource dict if it exists. If it does not |
|
53 | #Get the unique key from the resource dict if it exists. If it does not | |
54 |
#exist, use ' |
|
54 | #exist, use 'output' as the default. Also, get files directory if it | |
55 | #has been specified |
|
55 | #has been specified | |
56 |
unique_key = resources.get('unique_key', ' |
|
56 | unique_key = resources.get('unique_key', 'output') | |
57 | output_files_dir = resources.get('output_files_dir', None) |
|
57 | output_files_dir = resources.get('output_files_dir', None) | |
58 |
|
58 | |||
59 | #Make sure outputs key exists |
|
59 | #Make sure outputs key exists | |
@@ -79,8 +79,8 b' class ExtractOutputTransformer(Transformer):' | |||||
79 | else: |
|
79 | else: | |
80 | data = data.encode("UTF-8") |
|
80 | data = data.encode("UTF-8") | |
81 |
|
81 | |||
82 |
#Build a |
|
82 | #Build an output name | |
83 |
filename = self. |
|
83 | filename = self.output_filename_template.format( | |
84 | unique_key=unique_key, |
|
84 | unique_key=unique_key, | |
85 | cell_index=cell_index, |
|
85 | cell_index=cell_index, | |
86 | index=index, |
|
86 | index=index, |
@@ -36,7 +36,7 b' class DebugWriter(WriterBase):' | |||||
36 | if 'outputs' in resources: |
|
36 | if 'outputs' in resources: | |
37 | print("outputs extracted from %s" % notebook_name) |
|
37 | print("outputs extracted from %s" % notebook_name) | |
38 | print('-' * 80) |
|
38 | print('-' * 80) | |
39 |
|
|
39 | pprint(resources['outputs'], indent=2, width=70) | |
40 | else: |
|
40 | else: | |
41 |
print(" |
|
41 | print("no outputs extracted from %s" % notebook_name) | |
42 | print('=' * 80) |
|
42 | print('=' * 80) |
@@ -48,7 +48,7 b' class FilesWriter(WriterBase):' | |||||
48 |
|
48 | |||
49 | def _makedir(self, path): |
|
49 | def _makedir(self, path): | |
50 | """Make a directory if it doesn't already exist""" |
|
50 | """Make a directory if it doesn't already exist""" | |
51 | if not os.path.isdir(path): |
|
51 | if path and not os.path.isdir(path): | |
52 | self.log.info("Making directory %s", path) |
|
52 | self.log.info("Making directory %s", path) | |
53 | os.makedirs(path) |
|
53 | os.makedirs(path) | |
54 |
|
54 | |||
@@ -61,8 +61,12 b' class FilesWriter(WriterBase):' | |||||
61 | See base for more... |
|
61 | See base for more... | |
62 | """ |
|
62 | """ | |
63 |
|
63 | |||
|
64 | # Verify that a notebook name is provided. | |||
|
65 | if notebook_name is None: | |||
|
66 | raise TypeError('notebook_name') | |||
|
67 | ||||
64 | # Pull the extension and subdir from the resources dict. |
|
68 | # Pull the extension and subdir from the resources dict. | |
65 |
output_extension = resources |
|
69 | output_extension = resources.get('output_extension', None) | |
66 |
|
70 | |||
67 | # Write all of the extracted resources to the destination directory. |
|
71 | # Write all of the extracted resources to the destination directory. | |
68 | # NOTE: WE WRITE EVERYTHING AS-IF IT'S BINARY. THE EXTRACT FIG |
|
72 | # NOTE: WE WRITE EVERYTHING AS-IF IT'S BINARY. THE EXTRACT FIG | |
@@ -97,7 +101,10 b' class FilesWriter(WriterBase):' | |||||
97 | link_or_copy(matching_filename, dest) |
|
101 | link_or_copy(matching_filename, dest) | |
98 |
|
102 | |||
99 | # Determine where to write conversion results. |
|
103 | # Determine where to write conversion results. | |
100 | dest = notebook_name + '.' + output_extension |
|
104 | if output_extension is not None: | |
|
105 | dest = notebook_name + '.' + output_extension | |||
|
106 | else: | |||
|
107 | dest = notebook_name | |||
101 | if self.build_directory: |
|
108 | if self.build_directory: | |
102 | dest = os.path.join(self.build_directory, dest) |
|
109 | dest = os.path.join(self.build_directory, dest) | |
103 |
|
110 |
General Comments 0
You need to be logged in to leave comments.
Login now