Merge lp:~idlecool/sahana-eden/trunk into lp:sahana-eden

Proposed by Shiv Deepak
Status: Merged
Merged at revision: 2670
Proposed branch: lp:~idlecool/sahana-eden/trunk
Merge into: lp:sahana-eden
Diff against target: 210 lines (+35/-39)
1 file modified
modules/s3/s3pdf.py (+35/-39)
To merge this branch: bzr merge lp:~idlecool/sahana-eden/trunk
Reviewer Review Type Date Requested Status
Fran Boon Approve
Review via email: mp+71721@code.launchpad.net

Description of the change

Addresses FIXMEs in modules/s3/s3pdf.py, made UNIX style file paths portable.

To post a comment you must log in.
Revision history for this message
Fran Boon (flavour) wrote :

Thanks, however the issue wasn't just the ./application, but also the "uploads/ocr_meta/", "uploads/ocr_payload/", etc

review: Needs Fixing
lp:~idlecool/sahana-eden/trunk updated
2668. By Fran Boon

Approve action button should send user email confirmation, PR menu fixed, ACL improved

2669. By Fran Boon

Merge Graeme: S3Survey progress

Revision history for this message
Shiv Deepak (idlecool) wrote :

> Thanks, however the issue wasn't just the ./application, but also the
> "uploads/ocr_meta/", "uploads/ocr_payload/", etc

ahh. I separated them too.

Revision history for this message
Fran Boon (flavour) :
review: Approve
lp:~idlecool/sahana-eden/trunk updated
2670. By Fran Boon

merge idlecool: Fix portability of filepaths in OCR

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/s3/s3pdf.py'
2--- modules/s3/s3pdf.py 2011-08-16 11:49:37 +0000
3+++ modules/s3/s3pdf.py 2011-08-16 16:08:14 +0000
4@@ -126,7 +126,7 @@
5 Flowable.__init__(self)
6 self.doc = doc
7 self.title = newTitle
8-
9+
10 def draw(self):
11 self.doc.title = self.title
12
13@@ -135,7 +135,7 @@
14 Flowable.__init__(self)
15 self.function = callback
16 self.data = data
17-
18+
19 def draw(self):
20 self.function(self.canv, self.data)
21
22@@ -148,7 +148,7 @@
23 2) Even Page
24 3) Odd Page
25 4) Landscape Page
26-
27+
28 """
29
30 def setPageTemplates(self,
31@@ -193,7 +193,7 @@
32 def build(self, flowables, canvasmaker=canvas.Canvas):
33 """
34 build the document using the flowables.
35-
36+
37 Set up the page templates that the document can use
38
39 """
40@@ -341,7 +341,7 @@
41 id = r.id
42 except:
43 id = None
44-
45+
46 callback(self, id=id)
47 # build the document
48 doc = self.buildDoc()
49@@ -485,9 +485,9 @@
50 r.error(501, self.ERROR.INVALID_FORMID)
51
52 s3ocrxml_filename = row.s3ocrxml_file
53- f = open(os.path.join("./applications/",
54- self.request.application,
55- "uploads/ocr_meta/",
56+ f = open(os.path.join(r.folder,
57+ "uploads",
58+ "ocr_meta",
59 s3ocrxml_filename),
60 "rb")
61 s3ocrxml = f.read()
62@@ -528,10 +528,9 @@
63 r.error(501, self.manager.ERROR.BAD_RECORD)
64
65 s3ocrdataxml_filename = row.data_file
66- # FIXME!
67- f = open(os.path.join("./applications/",
68- self.request.application,
69- "uploads/ocr_payload/",
70+ f = open(os.path.join(r.folder,
71+ "uploads",
72+ "ocr_payload",
73 s3ocrdataxml_filename),
74 "rb")
75 s3ocrdataxml = f.read()
76@@ -588,11 +587,10 @@
77 r.error(501, self.manager.ERROR.BAD_RECORD)
78
79 format = row.image_file[-4:]
80- # FIXME!
81- image_file = open(os.path.join("./applications/",
82- self.request.application,
83- "uploads/ocr_payload/",
84- row.image_file))
85+ image_file = open(os.path.join(r.folder,
86+ "uploads",
87+ "ocr_payload",
88+ row.image_file))
89 image_file_content = image_file.read()
90 image_file.close()
91 # Set content type and disposition headers
92@@ -624,11 +622,10 @@
93 except(IndexError):
94 r.error(501, self.manager.ERROR.BAD_RECORD)
95
96- # FIXME!
97- data_file = open(os.path.join("./applications/",
98- self.request.application,
99- "uploads/ocr_payload/",
100- row.data_file))
101+ data_file = open(os.path.join(r.folder,
102+ "uploads",
103+ "ocr_payload",
104+ row.data_file))
105 formuuid = row.form_uuid
106
107 datafile_content = data_file.read()
108@@ -642,10 +639,9 @@
109 r.error(501, self.ERROR.INVALID_FORMID)
110
111 s3ocrxml_filename = row.s3ocrxml_file
112- # FIXME!
113- f = open(os.path.join("./applications/",
114- self.request.application,
115- "uploads/ocr_meta/",
116+ f = open(os.path.join(r.folder,
117+ "uploads",
118+ "ocr_meta",
119 s3ocrxml_filename),
120 "rb")
121 s3ocrxml = f.read()
122@@ -1673,7 +1669,7 @@
123 )
124 result = table.build()
125 if result != None:
126- self.content += result
127+ self.content += result
128
129
130 def addrHeader(self,
131@@ -1701,7 +1697,7 @@
132 )
133 result = rHeader.build()
134 if result != None:
135- self.content += result
136+ self.content += result
137
138 def addPlainTable(self, text, style=None, append=True):
139 table = Table(text, style=style)
140@@ -1793,7 +1789,7 @@
141 tempDoc.pagesize = portrait(self.paper_size)
142 tempDoc.build([tempTable], canvasmaker=canvas.Canvas)
143 return (tempTable._colWidths, tempTable._rowHeights)
144-
145+
146 def cellStyle(self, style, cell):
147 """
148 Add special styles to the text in a cell
149@@ -1803,7 +1799,7 @@
150 elif style == "*RED":
151 return [("TEXTCOLOR",cell, cell, colors.red)]
152 return []
153-
154+
155
156 def addCellStyling(self, table, style):
157 """
158@@ -1826,7 +1822,7 @@
159
160 def setHeaderBanner (self, image):
161 """
162- This method will add a banner to a page, used by pageHeader
163+ This method will add a banner to a page, used by pageHeader
164 """
165 self.headerBanner = os.path.join(current.request.folder,image)
166
167@@ -2199,7 +2195,7 @@
168 self.paper_size = LETTER
169 else:
170 self.paper_size = A4
171-
172+
173 self.pdf = document
174 self.resource = resource
175 self.raw_data = raw_data
176@@ -2477,7 +2473,7 @@
177 startRow = endRow
178 return pages
179 # End of function splitTable()
180-
181+
182 def tableStyle(self, startRow, rowCnt, endCol):
183 """
184 Internally used method to assign a style to the table
185@@ -3044,9 +3040,9 @@
186
187 pageimagefile = row["image_file"]
188 raw_images[eachpage] =\
189- Image.open(os.path.join("./applications/",
190- request.application,
191- "uploads/ocr_payload/",
192+ Image.open(os.path.join(self.r.folder,
193+ "uploads",
194+ "ocr_payload",
195 pageimagefile))
196
197 # transform each image
198@@ -3072,9 +3068,9 @@
199 self.__scaleFactor(images[each_img_index]["markers"])
200
201 # get layout file, convert it to etree
202- layout_file = open(os.path.join("./applications/",
203- request.application,
204- "uploads/ocr_meta/",
205+ layout_file = open(os.path.join(self.r.folder,
206+ "uploads",
207+ "ocr_meta",
208 layoutfilename),
209 "rb")
210 layout_xml = layout_file.read()