File: multiple_images_per_chunk.patch

package info (click to toggle)
knitpy 0.1.1~git20180430-2
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 832 kB
  • sloc: python: 1,571; makefile: 56
file content (38 lines) | stat: -rw-r--r-- 2,218 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Index: knitpy-0.1.1~git20170216/knitpy/documents.py
===================================================================
--- knitpy-0.1.1~git20170216.orig/knitpy/documents.py
+++ knitpy-0.1.1~git20170216/knitpy/documents.py
@@ -300,8 +300,10 @@ class TemporaryOutputDocument(LoggingCon
             mimedata = decodebytes(mimedata.encode())
             # save as a file
             if not self.context is None:
-                filename = u"%s-%s.%s" % (self.context.chunk_label,
+                self.context.number_of_images = self.context.number_of_images + 1
+                filename = u"%s-%s_img-%s.%s" % (self.context.chunk_label,
                                           self.context.chunk_plot_number,
+                                          self.context.number_of_images,
                                           IMAGE_MIMETYPE_TO_FILEEXTENSION[mimetype])
                 f = open(os.path.join(self.plotdir, filename), mode='w+b')
             else:
@@ -312,7 +314,7 @@ class TemporaryOutputDocument(LoggingCon
             f.write(mimedata)
             f.close()
             relative_name= "%s/%s/%s" % (self.outputdir, os.path.basename(self.plotdir),
-                                         os.path.basename(f.name))
+                                         os.path.basename(f.name), )
             self.log.info("Written file of type %s to %s", mimetype, relative_name)
             template = "![%s](%s)"
             self.add_asis("\n")
Index: knitpy-0.1.1~git20170216/knitpy/knitpy.py
===================================================================
--- knitpy-0.1.1~git20170216.orig/knitpy/knitpy.py
+++ knitpy-0.1.1~git20170216/knitpy/knitpy.py
@@ -814,6 +814,8 @@ class ExecutionContext(LoggingConfigurab
     chunk_label = Unicode(None, config=False, allow_none=True, help="current chunk label")
     chunk_plot_number = Integer(0, config=False, allow_none=False,
                                 help="current plot number in this chunk")
+    number_of_images = Integer(0, config=False, allow_none=False,
+                               help="number of images")
     def _chunk_label_changed(self, name, old, new):
         if old != new:
             self.chunk_plot_number = 0