Merge lp:~syleam/openobject-addons/5.0-improve-dms into lp:openobject-addons/5.0

Proposed by Christophe CHAUVET
Status: Merged
Merged at revision: not available
Proposed branch: lp:~syleam/openobject-addons/5.0-improve-dms
Merge into: lp:openobject-addons/5.0
Diff against target: None lines
To merge this branch: bzr merge lp:~syleam/openobject-addons/5.0-improve-dms
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+4098@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Christophe CHAUVET (christophe-chauvet) wrote :

Correct the bug 333223

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'document/__init__.py'
2--- document/__init__.py 2009-01-04 22:12:50 +0000
3+++ document/__init__.py 2009-03-03 09:51:57 +0000
4@@ -22,3 +22,5 @@
5
6 import document
7 import ftpserver
8+
9+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
10
11=== modified file 'document/__terp__.py'
12--- document/__terp__.py 2009-02-03 17:02:20 +0000
13+++ document/__terp__.py 2009-03-03 09:51:57 +0000
14@@ -45,4 +45,5 @@
15 'active': False,
16 'certificate': '0070515416461',
17 }
18+
19 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
20
21=== modified file 'document/content_index.py'
22--- document/content_index.py 2009-01-14 07:54:20 +0000
23+++ document/content_index.py 2009-03-03 09:51:57 +0000
24@@ -1,7 +1,7 @@
25 # -*- encoding: utf-8 -*-
26 ##############################################################################
27 #
28-# OpenERP, Open Source Management Solution
29+# OpenERP, Open Source Management Solution
30 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
31 # $Id$
32 #
33@@ -29,27 +29,29 @@
34 # This should be the indexer
35 #
36 def content_index(content, filename=None, content_type=None):
37- fname,ext = os.path.splitext(filename)
38- result = ''
39- if ext in ('.doc'): #or content_type ?
40- (stdin,stdout) = os.popen2('antiword -', 'b')
41- stdin.write(content)
42- stdin.close()
43- result = stdout.read().decode('latin1','replace').encode('utf-8','replace')
44- elif ext == '.pdf':
45- file_descriptor, file_name = tempfile.mkstemp(suffix=ext)
46- os.write(file_descriptor, content)
47- os.close(file_descriptor)
48- fp = os.popen('pdftotext -enc UTF-8 -nopgbrk '+file_name+' -', 'r')
49- result = fp.read()
50- fp.close()
51- elif ext in ('.xls','.ods','.odt','.odp'):
52- s = StringIO.StringIO(content)
53- o = odt2txt.OpenDocumentTextFile(s)
54- result = o.toString().encode('ascii','replace')
55- s.close()
56- elif ext in ('.txt','.py','.patch','.html','.csv','.xml'):
57- result = content
58- else:
59- result = content
60- return result
61+ fname,ext = os.path.splitext(filename)
62+ result = ''
63+ if ext in ('.doc'): #or content_type ?
64+ (stdin,stdout) = os.popen2('antiword -', 'b')
65+ stdin.write(content)
66+ stdin.close()
67+ result = stdout.read().decode('latin1','replace').encode('utf-8','replace')
68+ elif ext == '.pdf':
69+ file_descriptor, file_name = tempfile.mkstemp(suffix=ext)
70+ os.write(file_descriptor, content)
71+ os.close(file_descriptor)
72+ fp = os.popen('pdftotext -enc UTF-8 -nopgbrk '+file_name+' -', 'r')
73+ result = fp.read()
74+ fp.close()
75+ elif ext in ('.xls','.ods','.odt','.odp'):
76+ s = StringIO.StringIO(content)
77+ o = odt2txt.OpenDocumentTextFile(s)
78+ result = o.toString().encode('ascii','replace')
79+ s.close()
80+ elif ext in ('.txt','.py','.patch','.html','.csv','.xml'):
81+ result = content
82+ else:
83+ result = content
84+ return result
85+
86+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
87
88=== modified file 'document/document.py'
89--- document/document.py 2009-02-05 17:30:32 +0000
90+++ document/document.py 2009-03-03 09:51:57 +0000
91@@ -41,7 +41,7 @@
92
93 def random_name():
94 random.seed()
95- d = [random.choice(string.letters) for x in xrange(10) ]
96+ d = [random.choice(string.ascii_letters) for x in xrange(10) ]
97 name = "".join(d)
98 return name
99
100@@ -492,11 +492,11 @@
101 result = {}
102 cr.execute('select id,store_fname,link from ir_attachment where id in ('+','.join(map(str,ids))+')')
103 for id,r,l in cr.fetchall():
104- try:
105- value = file(os.path.join(self._get_filestore(cr), r), 'rb').read()
106- result[id] = base64.encodestring(value)
107- except:
108- result[id]=''
109+ try:
110+ value = file(os.path.join(self._get_filestore(cr), r), 'rb').read()
111+ result[id] = base64.encodestring(value)
112+ except:
113+ result[id]=''
114
115 if context.get('bin_size', False):
116 result[id] = tools.human_size(len(result[id]))
117@@ -581,7 +581,7 @@
118 res_id=file.res_id and file.res_id or 0
119 res=self.search(cr,uid,[('id','<>',file.id),('name','=',name),('parent_id','=',parent_id),('res_model','=',res_model),('res_id','=',res_id)])
120 if len(res):
121- return False
122+ return False
123 if op=='create':
124 res=self.search(cr,uid,[('name','=',name),('parent_id','=',parent_id),('res_id','=',res_id),('res_model','=',res_model)])
125 if len(res):
126@@ -771,3 +771,5 @@
127 'target':'new',
128 }
129 document_configuration_wizard()
130+
131+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
132
133=== modified file 'document/ftpserver/__init__.py'
134--- document/ftpserver/__init__.py 2008-12-18 08:55:57 +0000
135+++ document/ftpserver/__init__.py 2009-03-03 09:51:57 +0000
136@@ -1,3 +1,25 @@
137+# -*- encoding: utf-8 -*-
138+##############################################################################
139+#
140+# OpenERP, Open Source Management Solution
141+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
142+# $Id$
143+#
144+# This program is free software: you can redistribute it and/or modify
145+# it under the terms of the GNU General Public License as published by
146+# the Free Software Foundation, either version 3 of the License, or
147+# (at your option) any later version.
148+#
149+# This program is distributed in the hope that it will be useful,
150+# but WITHOUT ANY WARRANTY; without even the implied warranty of
151+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
152+# GNU General Public License for more details.
153+#
154+# You should have received a copy of the GNU General Public License
155+# along with this program. If not, see <http://www.gnu.org/licenses/>.
156+#
157+##############################################################################
158+
159 import threading
160 import ftpserver
161 import authorizer
162@@ -31,3 +53,4 @@
163 ds = ftp_server()
164 ds.start()
165
166+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
167
168=== modified file 'document/ftpserver/abstracted_fs.py'
169--- document/ftpserver/abstracted_fs.py 2009-01-02 06:00:20 +0000
170+++ document/ftpserver/abstracted_fs.py 2009-03-03 09:51:57 +0000
171@@ -1,3 +1,25 @@
172+# -*- encoding: utf-8 -*-
173+##############################################################################
174+#
175+# OpenERP, Open Source Management Solution
176+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
177+# $Id$
178+#
179+# This program is free software: you can redistribute it and/or modify
180+# it under the terms of the GNU General Public License as published by
181+# the Free Software Foundation, either version 3 of the License, or
182+# (at your option) any later version.
183+#
184+# This program is distributed in the hope that it will be useful,
185+# but WITHOUT ANY WARRANTY; without even the implied warranty of
186+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
187+# GNU General Public License for more details.
188+#
189+# You should have received a copy of the GNU General Public License
190+# along with this program. If not, see <http://www.gnu.org/licenses/>.
191+#
192+##############################################################################
193+
194 import os
195 import time
196 from tarfile import filemode
197@@ -788,3 +810,4 @@
198 yield "%s%s%s%s%s%s%s%s%s %s\r\n" %(type, size, perm, modify, create,
199 mode, uid, gid, unique, basename)
200
201+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
202
203=== modified file 'document/ftpserver/authorizer.py'
204--- document/ftpserver/authorizer.py 2008-10-29 21:45:02 +0000
205+++ document/ftpserver/authorizer.py 2009-03-03 09:51:57 +0000
206@@ -1,3 +1,25 @@
207+# -*- encoding: utf-8 -*-
208+##############################################################################
209+#
210+# OpenERP, Open Source Management Solution
211+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
212+# $Id$
213+#
214+# This program is free software: you can redistribute it and/or modify
215+# it under the terms of the GNU General Public License as published by
216+# the Free Software Foundation, either version 3 of the License, or
217+# (at your option) any later version.
218+#
219+# This program is distributed in the hope that it will be useful,
220+# but WITHOUT ANY WARRANTY; without even the implied warranty of
221+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
222+# GNU General Public License for more details.
223+#
224+# You should have received a copy of the GNU General Public License
225+# along with this program. If not, see <http://www.gnu.org/licenses/>.
226+#
227+##############################################################################
228+
229 #import pooler
230
231 class authorizer:
232@@ -68,4 +90,4 @@
233 """Return the user's quitting message."""
234 return 'Bye.'
235
236-
237+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
238
239=== modified file 'document/ftpserver/ftpserver.py'
240--- document/ftpserver/ftpserver.py 2008-12-18 08:55:57 +0000
241+++ document/ftpserver/ftpserver.py 2009-03-03 09:51:57 +0000
242@@ -1,4 +1,5 @@
243 #!/usr/bin/env python
244+# -*- encoding: utf-8 -*-
245 # ftpserver.py
246 #
247 # pyftpdlib is released under the MIT license, reproduced below:
248@@ -3094,3 +3095,5 @@
249
250 if __name__ == '__main__':
251 test()
252+
253+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
254
255=== modified file 'document/odt2txt.py'
256--- document/odt2txt.py 2009-01-04 22:12:50 +0000
257+++ document/odt2txt.py 2009-03-03 09:51:57 +0000
258@@ -2,7 +2,7 @@
259 # -*- encoding: utf-8 -*-
260 ##############################################################################
261 #
262-# OpenERP, Open Source Management Solution
263+# OpenERP, Open Source Management Solution
264 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
265 # $Id$
266 #
267@@ -25,28 +25,30 @@
268 import StringIO
269
270 class OpenDocumentTextFile :
271- def __init__ (self, filepath) :
272- zip = zipfile.ZipFile(filepath)
273- self.content = xml.dom.minidom.parseString(zip.read("content.xml"))
274-
275- def toString (self) :
276- """ Converts the document to a string. """
277- buffer = u""
278- for val in ["text:p", "text:h", "text:list"]:
279- for paragraph in self.content.getElementsByTagName(val) :
280- buffer += self.textToString(paragraph) + "\n"
281- return buffer
282-
283- def textToString(self, element) :
284- buffer = u""
285- for node in element.childNodes :
286- if node.nodeType == xml.dom.Node.TEXT_NODE :
287- buffer += node.nodeValue
288- elif node.nodeType == xml.dom.Node.ELEMENT_NODE :
289- buffer += self.textToString(node)
290- return buffer
291+ def __init__ (self, filepath) :
292+ zip = zipfile.ZipFile(filepath)
293+ self.content = xml.dom.minidom.parseString(zip.read("content.xml"))
294+
295+ def toString (self) :
296+ """ Converts the document to a string. """
297+ buffer = u""
298+ for val in ["text:p", "text:h", "text:list"]:
299+ for paragraph in self.content.getElementsByTagName(val) :
300+ buffer += self.textToString(paragraph) + "\n"
301+ return buffer
302+
303+ def textToString(self, element) :
304+ buffer = u""
305+ for node in element.childNodes :
306+ if node.nodeType == xml.dom.Node.TEXT_NODE :
307+ buffer += node.nodeValue
308+ elif node.nodeType == xml.dom.Node.ELEMENT_NODE :
309+ buffer += self.textToString(node)
310+ return buffer
311
312 if __name__ == "__main__" :
313- s =StringIO.StringIO(file(sys.argv[1]).read())
314- odt = OpenDocumentTextFile(s)
315- print odt.toString().encode('ascii','replace')
316+ s =StringIO.StringIO(file(sys.argv[1]).read())
317+ odt = OpenDocumentTextFile(s)
318+ print odt.toString().encode('ascii','replace')
319+
320+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
321
322=== modified file 'document_ics/__init__.py'
323--- document_ics/__init__.py 2009-01-04 22:12:50 +0000
324+++ document_ics/__init__.py 2009-03-03 09:51:57 +0000
325@@ -21,3 +21,5 @@
326 ##############################################################################
327
328 import document
329+
330+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: