diff --git a/addons/document/__init__.py b/addons/document/__init__.py index 135e4ac1635..2b9d7747b91 100644 --- a/addons/document/__init__.py +++ b/addons/document/__init__.py @@ -22,3 +22,5 @@ import document import ftpserver + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/document/__terp__.py b/addons/document/__terp__.py index f7e326bbc65..27c917f3deb 100644 --- a/addons/document/__terp__.py +++ b/addons/document/__terp__.py @@ -45,4 +45,5 @@ 'active': False, 'certificate': '0070515416461', } + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/document/content_index.py b/addons/document/content_index.py index 96297ff7a8b..a8d864905f4 100644 --- a/addons/document/content_index.py +++ b/addons/document/content_index.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved # $Id$ # @@ -29,27 +29,29 @@ import tempfile # This should be the indexer # def content_index(content, filename=None, content_type=None): - fname,ext = os.path.splitext(filename) - result = '' - if ext in ('.doc'): #or content_type ? - (stdin,stdout) = os.popen2('antiword -', 'b') - stdin.write(content) - stdin.close() - result = stdout.read().decode('latin1','replace').encode('utf-8','replace') - elif ext == '.pdf': - file_descriptor, file_name = tempfile.mkstemp(suffix=ext) - os.write(file_descriptor, content) - os.close(file_descriptor) - fp = os.popen('pdftotext -enc UTF-8 -nopgbrk '+file_name+' -', 'r') - result = fp.read() - fp.close() - elif ext in ('.xls','.ods','.odt','.odp'): - s = StringIO.StringIO(content) - o = odt2txt.OpenDocumentTextFile(s) - result = o.toString().encode('ascii','replace') - s.close() - elif ext in ('.txt','.py','.patch','.html','.csv','.xml'): - result = content - else: - result = content - return result + fname,ext = os.path.splitext(filename) + result = '' + if ext in ('.doc'): #or content_type ? + (stdin,stdout) = os.popen2('antiword -', 'b') + stdin.write(content) + stdin.close() + result = stdout.read().decode('latin1','replace').encode('utf-8','replace') + elif ext == '.pdf': + file_descriptor, file_name = tempfile.mkstemp(suffix=ext) + os.write(file_descriptor, content) + os.close(file_descriptor) + fp = os.popen('pdftotext -enc UTF-8 -nopgbrk '+file_name+' -', 'r') + result = fp.read() + fp.close() + elif ext in ('.xls','.ods','.odt','.odp'): + s = StringIO.StringIO(content) + o = odt2txt.OpenDocumentTextFile(s) + result = o.toString().encode('ascii','replace') + s.close() + elif ext in ('.txt','.py','.patch','.html','.csv','.xml'): + result = content + else: + result = content + return result + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/document/document.py b/addons/document/document.py index e86d90e4643..31ab13ae4df 100644 --- a/addons/document/document.py +++ b/addons/document/document.py @@ -492,11 +492,11 @@ class document_file(osv.osv): result = {} cr.execute('select id,store_fname,link from ir_attachment where id in ('+','.join(map(str,ids))+')') for id,r,l in cr.fetchall(): - try: - value = file(os.path.join(self._get_filestore(cr), r), 'rb').read() - result[id] = base64.encodestring(value) - except: - result[id]='' + try: + value = file(os.path.join(self._get_filestore(cr), r), 'rb').read() + result[id] = base64.encodestring(value) + except: + result[id]='' if context.get('bin_size', False): result[id] = tools.human_size(len(result[id])) @@ -581,7 +581,7 @@ class document_file(osv.osv): res_id=file.res_id and file.res_id or 0 res=self.search(cr,uid,[('id','<>',file.id),('name','=',name),('parent_id','=',parent_id),('res_model','=',res_model),('res_id','=',res_id)]) if len(res): - return False + return False if op=='create': res=self.search(cr,uid,[('name','=',name),('parent_id','=',parent_id),('res_id','=',res_id),('res_model','=',res_model)]) if len(res): @@ -771,3 +771,5 @@ class document_configuration_wizard(osv.osv_memory): 'target':'new', } document_configuration_wizard() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/document/ftpserver/__init__.py b/addons/document/ftpserver/__init__.py index dcac53d6061..35d1107ad81 100644 --- a/addons/document/ftpserver/__init__.py +++ b/addons/document/ftpserver/__init__.py @@ -1,3 +1,25 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + import threading import ftpserver import authorizer @@ -31,3 +53,4 @@ class ftp_server(threading.Thread): ds = ftp_server() ds.start() +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/document/ftpserver/abstracted_fs.py b/addons/document/ftpserver/abstracted_fs.py index 9b8b78b6e8a..155c68ae515 100644 --- a/addons/document/ftpserver/abstracted_fs.py +++ b/addons/document/ftpserver/abstracted_fs.py @@ -1,3 +1,5 @@ +# -*- encoding: utf-8 -*- + import os import time from tarfile import filemode @@ -788,3 +790,4 @@ class abstracted_fs: yield "%s%s%s%s%s%s%s%s%s %s\r\n" %(type, size, perm, modify, create, mode, uid, gid, unique, basename) +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/document/ftpserver/authorizer.py b/addons/document/ftpserver/authorizer.py index fa45f0c3183..5a64ca8f7a0 100644 --- a/addons/document/ftpserver/authorizer.py +++ b/addons/document/ftpserver/authorizer.py @@ -1,4 +1,4 @@ -#import pooler +# -*- encoding: utf-8 -*- class authorizer: read_perms = "elr" @@ -68,4 +68,4 @@ class authorizer: """Return the user's quitting message.""" return 'Bye.' - +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/document/ftpserver/ftpserver.py b/addons/document/ftpserver/ftpserver.py index 07f60344b74..ae0fc38e1e1 100644 --- a/addons/document/ftpserver/ftpserver.py +++ b/addons/document/ftpserver/ftpserver.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# -*- encoding: utf-8 -*- # ftpserver.py # # pyftpdlib is released under the MIT license, reproduced below: @@ -3094,3 +3095,5 @@ def test(): if __name__ == '__main__': test() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/document/odt2txt.py b/addons/document/odt2txt.py index 7cc10bf04cd..55c228498fa 100644 --- a/addons/document/odt2txt.py +++ b/addons/document/odt2txt.py @@ -2,7 +2,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved # $Id$ # @@ -25,28 +25,30 @@ import sys, zipfile, xml.dom.minidom import StringIO class OpenDocumentTextFile : - def __init__ (self, filepath) : - zip = zipfile.ZipFile(filepath) - self.content = xml.dom.minidom.parseString(zip.read("content.xml")) + def __init__ (self, filepath) : + zip = zipfile.ZipFile(filepath) + self.content = xml.dom.minidom.parseString(zip.read("content.xml")) - def toString (self) : - """ Converts the document to a string. """ - buffer = u"" - for val in ["text:p", "text:h", "text:list"]: - for paragraph in self.content.getElementsByTagName(val) : - buffer += self.textToString(paragraph) + "\n" - return buffer + def toString (self) : + """ Converts the document to a string. """ + buffer = u"" + for val in ["text:p", "text:h", "text:list"]: + for paragraph in self.content.getElementsByTagName(val) : + buffer += self.textToString(paragraph) + "\n" + return buffer - def textToString(self, element) : - buffer = u"" - for node in element.childNodes : - if node.nodeType == xml.dom.Node.TEXT_NODE : - buffer += node.nodeValue - elif node.nodeType == xml.dom.Node.ELEMENT_NODE : - buffer += self.textToString(node) - return buffer + def textToString(self, element) : + buffer = u"" + for node in element.childNodes : + if node.nodeType == xml.dom.Node.TEXT_NODE : + buffer += node.nodeValue + elif node.nodeType == xml.dom.Node.ELEMENT_NODE : + buffer += self.textToString(node) + return buffer if __name__ == "__main__" : - s =StringIO.StringIO(file(sys.argv[1]).read()) - odt = OpenDocumentTextFile(s) - print odt.toString().encode('ascii','replace') + s =StringIO.StringIO(file(sys.argv[1]).read()) + odt = OpenDocumentTextFile(s) + print odt.toString().encode('ascii','replace') + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/document_ics/__init__.py b/addons/document_ics/__init__.py index 1aa5ae04ca6..fd99a5c7b30 100644 --- a/addons/document_ics/__init__.py +++ b/addons/document_ics/__init__.py @@ -21,3 +21,5 @@ ############################################################################## import document + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: