incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r1366506 - in /incubator/ooo/trunk/main/scripting/source/pyprov: mailmerge.py officehelper.py pythonscript.py
Date Fri, 27 Jul 2012 19:16:58 GMT
Author: pfg
Date: Fri Jul 27 19:16:57 2012
New Revision: 1366506

URL: http://svn.apache.org/viewvc?rev=1366506&view=rev
Log:
i119384 - Python: replace deprecated compiler module with ast

The "compiler" module is deprecated on Python 2.6 and was
removed on 3.x so it's a good time to replace it. The
ast module was introduced in Python 2.5 so this will cause
trouble if using very old versions of system python.

While here run the python reindent tool on the adjacent
files.

Author:	hanya 

Modified:
    incubator/ooo/trunk/main/scripting/source/pyprov/mailmerge.py
    incubator/ooo/trunk/main/scripting/source/pyprov/officehelper.py
    incubator/ooo/trunk/main/scripting/source/pyprov/pythonscript.py

Modified: incubator/ooo/trunk/main/scripting/source/pyprov/mailmerge.py
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/scripting/source/pyprov/mailmerge.py?rev=1366506&r1=1366505&r2=1366506&view=diff
==============================================================================
--- incubator/ooo/trunk/main/scripting/source/pyprov/mailmerge.py (original)
+++ incubator/ooo/trunk/main/scripting/source/pyprov/mailmerge.py Fri Jul 27 19:16:57 2012
@@ -68,423 +68,423 @@ import sys, smtplib, imaplib, poplib
 dbg = False
 
 class PyMailSMTPService(unohelper.Base, XSmtpService):
-	def __init__( self, ctx ):
-		self.ctx = ctx
-		self.listeners = []
-		self.supportedtypes = ('Insecure', 'Ssl')
-		self.server = None
-		self.connectioncontext = None
-		self.notify = EventObject(self)
-		if dbg:
-			print >> sys.stderr, "PyMailSMPTService init"
-	def addConnectionListener(self, xListener):
-		if dbg:
-			print >> sys.stderr, "PyMailSMPTService addConnectionListener"
-		self.listeners.append(xListener)
-	def removeConnectionListener(self, xListener):
-		if dbg:
-			print >> sys.stderr, "PyMailSMPTService removeConnectionListener"
-		self.listeners.remove(xListener)
-	def getSupportedConnectionTypes(self):
-		if dbg:
-			print >> sys.stderr, "PyMailSMPTService getSupportedConnectionTypes"
-		return self.supportedtypes
-	def connect(self, xConnectionContext, xAuthenticator):
-		self.connectioncontext = xConnectionContext
-		if dbg:
-			print >> sys.stderr, "PyMailSMPTService connect"
-
-		server = xConnectionContext.getValueByName("ServerName")
-		if dbg:
-			print >> sys.stderr, "ServerName: %s" % server
-
-		port = xConnectionContext.getValueByName("Port")
-		if dbg:
-			print >> sys.stderr, "Port: %d" % port
-
-		tout = xConnectionContext.getValueByName("Timeout")
-		if dbg:
-			print >> sys.stderr, isinstance(tout,int)
-		if not isinstance(tout,int):
-			tout = _GLOBAL_DEFAULT_TIMEOUT
-		if dbg:
-			print >> sys.stderr, "Timeout: %s" % str(tout)
-
-		self.server = smtplib.SMTP(server, port,timeout=tout)
-		if dbg:
-			self.server.set_debuglevel(1)
-
-		connectiontype = xConnectionContext.getValueByName("ConnectionType")
-		if dbg:
-			print >> sys.stderr, "ConnectionType: %s" % connectiontype
-
-		if connectiontype.upper() == 'SSL':
-			self.server.ehlo()
-			self.server.starttls()
-			self.server.ehlo()
-
-		user = xAuthenticator.getUserName().encode('ascii')
-		password = xAuthenticator.getPassword().encode('ascii')
-		if user != '':
-			if dbg:
-				print >> sys.stderr, 'Logging in, username of', user
-			self.server.login(user, password)
-
-		for listener in self.listeners:
-			listener.connected(self.notify)
-	def disconnect(self):
-		if dbg:
-			print >> sys.stderr, "PyMailSMPTService disconnect"
-		if self.server:
-			self.server.quit()
-			self.server = None
-		for listener in self.listeners:
-			listener.disconnected(self.notify)
-	def isConnected(self):
-		if dbg:
-			print >> sys.stderr, "PyMailSMPTService isConnected"
-		return self.server != None
-	def getCurrentConnectionContext(self):
-		if dbg:
-			print >> sys.stderr, "PyMailSMPTService getCurrentConnectionContext"
-		return self.connectioncontext
-	def sendMailMessage(self, xMailMessage):
-		COMMASPACE = ', '
-
-		if dbg:
-			print >> sys.stderr, "PyMailSMPTService sendMailMessage"
-		recipients = xMailMessage.getRecipients()
-		sendermail = xMailMessage.SenderAddress
-		sendername = xMailMessage.SenderName
-		subject = xMailMessage.Subject
-		ccrecipients = xMailMessage.getCcRecipients()
-		bccrecipients = xMailMessage.getBccRecipients()
-		if dbg:
-			print >> sys.stderr, "PyMailSMPTService subject", subject
-			print >> sys.stderr, "PyMailSMPTService from", sendername.encode('utf-8')
-			print >> sys.stderr, "PyMailSMTPService from", sendermail
-			print >> sys.stderr, "PyMailSMPTService send to", recipients
-
-		attachments = xMailMessage.getAttachments()
-
-		textmsg = Message()
-
-		content = xMailMessage.Body
-		flavors = content.getTransferDataFlavors()
-		if dbg:
-			print >> sys.stderr, "PyMailSMPTService flavors len", len(flavors)
-
-		#Use first flavor that's sane for an email body
-		for flavor in flavors:
-			if flavor.MimeType.find('text/html') != -1 or flavor.MimeType.find('text/plain') != -1:
-				if dbg:
-					print >> sys.stderr, "PyMailSMPTService mimetype is", flavor.MimeType
-				textbody = content.getTransferData(flavor)
-				try:
-					textbody = textbody.value
-				except:
-					pass
-				textbody = textbody.encode('utf-8')
-
-				if len(textbody):
-					mimeEncoding = re.sub("charset=.*", "charset=UTF-8", flavor.MimeType)
-					if mimeEncoding.find('charset=UTF-8') == -1:
-						mimeEncoding = mimeEncoding + "; charset=UTF-8"
-					textmsg['Content-Type'] = mimeEncoding
-					textmsg['MIME-Version'] = '1.0'
-					textmsg.set_payload(textbody)
-
-				break
-
-		if (len(attachments)):
-			msg = MIMEMultipart()
-			msg.epilogue = ''
-			msg.attach(textmsg)
-		else:
-			msg = textmsg
-
-		hdr = Header(sendername, 'utf-8')
-		hdr.append('<'+sendermail+'>','us-ascii')
-		msg['Subject'] = subject
-		msg['From'] = hdr
-		msg['To'] = COMMASPACE.join(recipients)
-		if len(ccrecipients):
-			msg['Cc'] = COMMASPACE.join(ccrecipients)
-		if xMailMessage.ReplyToAddress != '':
-			msg['Reply-To'] = xMailMessage.ReplyToAddress
-
-		mailerstring = "OpenOffice.org 2.0 via Caolan's mailmerge component"
-		try:
-			ctx = uno.getComponentContext()
-			aConfigProvider = ctx.ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider")
-			prop = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
-			prop.Name = "nodepath"
-			prop.Value = "/org.openoffice.Setup/Product"
-			aSettings = aConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess",
-				(prop,))
-			mailerstring = aSettings.getByName("ooName") + " " + \
-				aSettings.getByName("ooSetupVersion") + " via Caolan's mailmerge component"
-		except:
-			pass
-
-		msg['X-Mailer'] = mailerstring
-		msg['Date'] = formatdate(localtime=True)
-
-		for attachment in attachments:
-			content = attachment.Data
-			flavors = content.getTransferDataFlavors()
-			flavor = flavors[0]
-			ctype = flavor.MimeType
-			maintype, subtype = ctype.split('/', 1)
-			msgattachment = MIMEBase(maintype, subtype)
-			data = content.getTransferData(flavor)
-			msgattachment.set_payload(data)
-			Encoders.encode_base64(msgattachment)
-			fname = attachment.ReadableName
-			try:
-				fname.encode('ascii')
-			except:
-				fname = ('utf-8','',fname.encode('utf-8'))
-			msgattachment.add_header('Content-Disposition', 'attachment', \
-				filename=fname)
-			msg.attach(msgattachment)
-
-		uniquer = {}
-		for key in recipients:
-			uniquer[key] = True
-		if len(ccrecipients):
-			for key in ccrecipients:
-				uniquer[key] = True
-		if len(bccrecipients):
-			for key in bccrecipients:
-				uniquer[key] = True
-		truerecipients = uniquer.keys()
+    def __init__( self, ctx ):
+        self.ctx = ctx
+        self.listeners = []
+        self.supportedtypes = ('Insecure', 'Ssl')
+        self.server = None
+        self.connectioncontext = None
+        self.notify = EventObject(self)
+        if dbg:
+            print >> sys.stderr, "PyMailSMPTService init"
+    def addConnectionListener(self, xListener):
+        if dbg:
+            print >> sys.stderr, "PyMailSMPTService addConnectionListener"
+        self.listeners.append(xListener)
+    def removeConnectionListener(self, xListener):
+        if dbg:
+            print >> sys.stderr, "PyMailSMPTService removeConnectionListener"
+        self.listeners.remove(xListener)
+    def getSupportedConnectionTypes(self):
+        if dbg:
+            print >> sys.stderr, "PyMailSMPTService getSupportedConnectionTypes"
+        return self.supportedtypes
+    def connect(self, xConnectionContext, xAuthenticator):
+        self.connectioncontext = xConnectionContext
+        if dbg:
+            print >> sys.stderr, "PyMailSMPTService connect"
+
+        server = xConnectionContext.getValueByName("ServerName")
+        if dbg:
+            print >> sys.stderr, "ServerName: %s" % server
+
+        port = xConnectionContext.getValueByName("Port")
+        if dbg:
+            print >> sys.stderr, "Port: %d" % port
+
+        tout = xConnectionContext.getValueByName("Timeout")
+        if dbg:
+            print >> sys.stderr, isinstance(tout,int)
+        if not isinstance(tout,int):
+            tout = _GLOBAL_DEFAULT_TIMEOUT
+        if dbg:
+            print >> sys.stderr, "Timeout: %s" % str(tout)
+
+        self.server = smtplib.SMTP(server, port,timeout=tout)
+        if dbg:
+            self.server.set_debuglevel(1)
+
+        connectiontype = xConnectionContext.getValueByName("ConnectionType")
+        if dbg:
+            print >> sys.stderr, "ConnectionType: %s" % connectiontype
+
+        if connectiontype.upper() == 'SSL':
+            self.server.ehlo()
+            self.server.starttls()
+            self.server.ehlo()
+
+        user = xAuthenticator.getUserName().encode('ascii')
+        password = xAuthenticator.getPassword().encode('ascii')
+        if user != '':
+            if dbg:
+                print >> sys.stderr, 'Logging in, username of', user
+            self.server.login(user, password)
+
+        for listener in self.listeners:
+            listener.connected(self.notify)
+    def disconnect(self):
+        if dbg:
+            print >> sys.stderr, "PyMailSMPTService disconnect"
+        if self.server:
+            self.server.quit()
+            self.server = None
+        for listener in self.listeners:
+            listener.disconnected(self.notify)
+    def isConnected(self):
+        if dbg:
+            print >> sys.stderr, "PyMailSMPTService isConnected"
+        return self.server != None
+    def getCurrentConnectionContext(self):
+        if dbg:
+            print >> sys.stderr, "PyMailSMPTService getCurrentConnectionContext"
+        return self.connectioncontext
+    def sendMailMessage(self, xMailMessage):
+        COMMASPACE = ', '
+
+        if dbg:
+            print >> sys.stderr, "PyMailSMPTService sendMailMessage"
+        recipients = xMailMessage.getRecipients()
+        sendermail = xMailMessage.SenderAddress
+        sendername = xMailMessage.SenderName
+        subject = xMailMessage.Subject
+        ccrecipients = xMailMessage.getCcRecipients()
+        bccrecipients = xMailMessage.getBccRecipients()
+        if dbg:
+            print >> sys.stderr, "PyMailSMPTService subject", subject
+            print >> sys.stderr, "PyMailSMPTService from", sendername.encode('utf-8')
+            print >> sys.stderr, "PyMailSMTPService from", sendermail
+            print >> sys.stderr, "PyMailSMPTService send to", recipients
+
+        attachments = xMailMessage.getAttachments()
+
+        textmsg = Message()
+
+        content = xMailMessage.Body
+        flavors = content.getTransferDataFlavors()
+        if dbg:
+            print >> sys.stderr, "PyMailSMPTService flavors len", len(flavors)
+
+        #Use first flavor that's sane for an email body
+        for flavor in flavors:
+            if flavor.MimeType.find('text/html') != -1 or flavor.MimeType.find('text/plain') != -1:
+                if dbg:
+                    print >> sys.stderr, "PyMailSMPTService mimetype is", flavor.MimeType
+                textbody = content.getTransferData(flavor)
+                try:
+                    textbody = textbody.value
+                except:
+                    pass
+                textbody = textbody.encode('utf-8')
+
+                if len(textbody):
+                    mimeEncoding = re.sub("charset=.*", "charset=UTF-8", flavor.MimeType)
+                    if mimeEncoding.find('charset=UTF-8') == -1:
+                        mimeEncoding = mimeEncoding + "; charset=UTF-8"
+                    textmsg['Content-Type'] = mimeEncoding
+                    textmsg['MIME-Version'] = '1.0'
+                    textmsg.set_payload(textbody)
+
+                break
+
+        if (len(attachments)):
+            msg = MIMEMultipart()
+            msg.epilogue = ''
+            msg.attach(textmsg)
+        else:
+            msg = textmsg
+
+        hdr = Header(sendername, 'utf-8')
+        hdr.append('<'+sendermail+'>','us-ascii')
+        msg['Subject'] = subject
+        msg['From'] = hdr
+        msg['To'] = COMMASPACE.join(recipients)
+        if len(ccrecipients):
+            msg['Cc'] = COMMASPACE.join(ccrecipients)
+        if xMailMessage.ReplyToAddress != '':
+            msg['Reply-To'] = xMailMessage.ReplyToAddress
+
+        mailerstring = "OpenOffice.org 2.0 via Caolan's mailmerge component"
+        try:
+            ctx = uno.getComponentContext()
+            aConfigProvider = ctx.ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider")
+            prop = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
+            prop.Name = "nodepath"
+            prop.Value = "/org.openoffice.Setup/Product"
+            aSettings = aConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess",
+                    (prop,))
+            mailerstring = aSettings.getByName("ooName") + " " + \
+                    aSettings.getByName("ooSetupVersion") + " via Caolan's mailmerge component"
+        except:
+            pass
+
+        msg['X-Mailer'] = mailerstring
+        msg['Date'] = formatdate(localtime=True)
+
+        for attachment in attachments:
+            content = attachment.Data
+            flavors = content.getTransferDataFlavors()
+            flavor = flavors[0]
+            ctype = flavor.MimeType
+            maintype, subtype = ctype.split('/', 1)
+            msgattachment = MIMEBase(maintype, subtype)
+            data = content.getTransferData(flavor)
+            msgattachment.set_payload(data)
+            Encoders.encode_base64(msgattachment)
+            fname = attachment.ReadableName
+            try:
+                fname.encode('ascii')
+            except:
+                fname = ('utf-8','',fname.encode('utf-8'))
+            msgattachment.add_header('Content-Disposition', 'attachment', \
+                    filename=fname)
+            msg.attach(msgattachment)
+
+        uniquer = {}
+        for key in recipients:
+            uniquer[key] = True
+        if len(ccrecipients):
+            for key in ccrecipients:
+                uniquer[key] = True
+        if len(bccrecipients):
+            for key in bccrecipients:
+                uniquer[key] = True
+        truerecipients = uniquer.keys()
 
-		if dbg:
-			print >> sys.stderr, "PyMailSMPTService recipients are", truerecipients
+        if dbg:
+            print >> sys.stderr, "PyMailSMPTService recipients are", truerecipients
 
-		self.server.sendmail(sendermail, truerecipients, msg.as_string())
+        self.server.sendmail(sendermail, truerecipients, msg.as_string())
 
 class PyMailIMAPService(unohelper.Base, XMailService):
-	def __init__( self, ctx ):
-		self.ctx = ctx
-		self.listeners = []
-		self.supportedtypes = ('Insecure', 'Ssl')
-		self.server = None
-		self.connectioncontext = None
-		self.notify = EventObject(self)
-		if dbg:
-			print >> sys.stderr, "PyMailIMAPService init"
-	def addConnectionListener(self, xListener):
-		if dbg:
-			print >> sys.stderr, "PyMailIMAPService addConnectionListener"
-		self.listeners.append(xListener)
-	def removeConnectionListener(self, xListener):
-		if dbg:
-			print >> sys.stderr, "PyMailIMAPService removeConnectionListener"
-		self.listeners.remove(xListener)
-	def getSupportedConnectionTypes(self):
-		if dbg:
-			print >> sys.stderr, "PyMailIMAPService getSupportedConnectionTypes"
-		return self.supportedtypes
-	def connect(self, xConnectionContext, xAuthenticator):
-		if dbg:
-			print >> sys.stderr, "PyMailIMAPService connect"
-
-		self.connectioncontext = xConnectionContext
-		server = xConnectionContext.getValueByName("ServerName")
-		if dbg:
-			print >> sys.stderr, server
-		port = xConnectionContext.getValueByName("Port")
-		if dbg:
-			print >> sys.stderr, port
-		connectiontype = xConnectionContext.getValueByName("ConnectionType")
-		if dbg:
-			print >> sys.stderr, connectiontype
-		print >> sys.stderr, "BEFORE"
-		if connectiontype.upper() == 'SSL':
-			self.server = imaplib.IMAP4_SSL(server, port)
-		else:
-			self.server = imaplib.IMAP4(server, port)
-		print >> sys.stderr, "AFTER"
-
-		user = xAuthenticator.getUserName().encode('ascii')
-		password = xAuthenticator.getPassword().encode('ascii')
-		if user != '':
-			if dbg:
-				print >> sys.stderr, 'Logging in, username of', user
-			self.server.login(user, password)
-
-		for listener in self.listeners:
-			listener.connected(self.notify)
-	def disconnect(self):
-		if dbg:
-			print >> sys.stderr, "PyMailIMAPService disconnect"
-		if self.server:
-			self.server.logout()
-			self.server = None
-		for listener in self.listeners:
-			listener.disconnected(self.notify)
-	def isConnected(self):
-		if dbg:
-			print >> sys.stderr, "PyMailIMAPService isConnected"
-		return self.server != None
-	def getCurrentConnectionContext(self):
-		if dbg:
-			print >> sys.stderr, "PyMailIMAPService getCurrentConnectionContext"
-		return self.connectioncontext
+    def __init__( self, ctx ):
+        self.ctx = ctx
+        self.listeners = []
+        self.supportedtypes = ('Insecure', 'Ssl')
+        self.server = None
+        self.connectioncontext = None
+        self.notify = EventObject(self)
+        if dbg:
+            print >> sys.stderr, "PyMailIMAPService init"
+    def addConnectionListener(self, xListener):
+        if dbg:
+            print >> sys.stderr, "PyMailIMAPService addConnectionListener"
+        self.listeners.append(xListener)
+    def removeConnectionListener(self, xListener):
+        if dbg:
+            print >> sys.stderr, "PyMailIMAPService removeConnectionListener"
+        self.listeners.remove(xListener)
+    def getSupportedConnectionTypes(self):
+        if dbg:
+            print >> sys.stderr, "PyMailIMAPService getSupportedConnectionTypes"
+        return self.supportedtypes
+    def connect(self, xConnectionContext, xAuthenticator):
+        if dbg:
+            print >> sys.stderr, "PyMailIMAPService connect"
+
+        self.connectioncontext = xConnectionContext
+        server = xConnectionContext.getValueByName("ServerName")
+        if dbg:
+            print >> sys.stderr, server
+        port = xConnectionContext.getValueByName("Port")
+        if dbg:
+            print >> sys.stderr, port
+        connectiontype = xConnectionContext.getValueByName("ConnectionType")
+        if dbg:
+            print >> sys.stderr, connectiontype
+        print >> sys.stderr, "BEFORE"
+        if connectiontype.upper() == 'SSL':
+            self.server = imaplib.IMAP4_SSL(server, port)
+        else:
+            self.server = imaplib.IMAP4(server, port)
+        print >> sys.stderr, "AFTER"
+
+        user = xAuthenticator.getUserName().encode('ascii')
+        password = xAuthenticator.getPassword().encode('ascii')
+        if user != '':
+            if dbg:
+                print >> sys.stderr, 'Logging in, username of', user
+            self.server.login(user, password)
+
+        for listener in self.listeners:
+            listener.connected(self.notify)
+    def disconnect(self):
+        if dbg:
+            print >> sys.stderr, "PyMailIMAPService disconnect"
+        if self.server:
+            self.server.logout()
+            self.server = None
+        for listener in self.listeners:
+            listener.disconnected(self.notify)
+    def isConnected(self):
+        if dbg:
+            print >> sys.stderr, "PyMailIMAPService isConnected"
+        return self.server != None
+    def getCurrentConnectionContext(self):
+        if dbg:
+            print >> sys.stderr, "PyMailIMAPService getCurrentConnectionContext"
+        return self.connectioncontext
 
 class PyMailPOP3Service(unohelper.Base, XMailService):
-	def __init__( self, ctx ):
-		self.ctx = ctx
-		self.listeners = []
-		self.supportedtypes = ('Insecure', 'Ssl')
-		self.server = None
-		self.connectioncontext = None
-		self.notify = EventObject(self)
-		if dbg:
-			print >> sys.stderr, "PyMailPOP3Service init"
-	def addConnectionListener(self, xListener):
-		if dbg:
-			print >> sys.stderr, "PyMailPOP3Service addConnectionListener"
-		self.listeners.append(xListener)
-	def removeConnectionListener(self, xListener):
-		if dbg:
-			print >> sys.stderr, "PyMailPOP3Service removeConnectionListener"
-		self.listeners.remove(xListener)
-	def getSupportedConnectionTypes(self):
-		if dbg:
-			print >> sys.stderr, "PyMailPOP3Service getSupportedConnectionTypes"
-		return self.supportedtypes
-	def connect(self, xConnectionContext, xAuthenticator):
-		if dbg:
-			print >> sys.stderr, "PyMailPOP3Service connect"
-
-		self.connectioncontext = xConnectionContext
-		server = xConnectionContext.getValueByName("ServerName")
-		if dbg:
-			print >> sys.stderr, server
-		port = xConnectionContext.getValueByName("Port")
-		if dbg:
-			print >> sys.stderr, port
-		connectiontype = xConnectionContext.getValueByName("ConnectionType")
-		if dbg:
-			print >> sys.stderr, connectiontype
-		print >> sys.stderr, "BEFORE"
-		if connectiontype.upper() == 'SSL':
-			self.server = poplib.POP3_SSL(server, port)
-		else:
-			tout = xConnectionContext.getValueByName("Timeout")
-			if dbg:
-				print >> sys.stderr, isinstance(tout,int)
-			if not isinstance(tout,int):
-				tout = _GLOBAL_DEFAULT_TIMEOUT
-			if dbg:
-				print >> sys.stderr, "Timeout: %s" % str(tout)
-			self.server = poplib.POP3(server, port, timeout=tout)
-		print >> sys.stderr, "AFTER"
-
-		user = xAuthenticator.getUserName().encode('ascii')
-		password = xAuthenticator.getPassword().encode('ascii')
-		if dbg:
-			print >> sys.stderr, 'Logging in, username of', user
-		self.server.user(user)
-		self.server.pass_(password)
-
-		for listener in self.listeners:
-			listener.connected(self.notify)
-	def disconnect(self):
-		if dbg:
-			print >> sys.stderr, "PyMailPOP3Service disconnect"
-		if self.server:
-			self.server.quit()
-			self.server = None
-		for listener in self.listeners:
-			listener.disconnected(self.notify)
-	def isConnected(self):
-		if dbg:
-			print >> sys.stderr, "PyMailPOP3Service isConnected"
-		return self.server != None
-	def getCurrentConnectionContext(self):
-		if dbg:
-			print >> sys.stderr, "PyMailPOP3Service getCurrentConnectionContext"
-		return self.connectioncontext
+    def __init__( self, ctx ):
+        self.ctx = ctx
+        self.listeners = []
+        self.supportedtypes = ('Insecure', 'Ssl')
+        self.server = None
+        self.connectioncontext = None
+        self.notify = EventObject(self)
+        if dbg:
+            print >> sys.stderr, "PyMailPOP3Service init"
+    def addConnectionListener(self, xListener):
+        if dbg:
+            print >> sys.stderr, "PyMailPOP3Service addConnectionListener"
+        self.listeners.append(xListener)
+    def removeConnectionListener(self, xListener):
+        if dbg:
+            print >> sys.stderr, "PyMailPOP3Service removeConnectionListener"
+        self.listeners.remove(xListener)
+    def getSupportedConnectionTypes(self):
+        if dbg:
+            print >> sys.stderr, "PyMailPOP3Service getSupportedConnectionTypes"
+        return self.supportedtypes
+    def connect(self, xConnectionContext, xAuthenticator):
+        if dbg:
+            print >> sys.stderr, "PyMailPOP3Service connect"
+
+        self.connectioncontext = xConnectionContext
+        server = xConnectionContext.getValueByName("ServerName")
+        if dbg:
+            print >> sys.stderr, server
+        port = xConnectionContext.getValueByName("Port")
+        if dbg:
+            print >> sys.stderr, port
+        connectiontype = xConnectionContext.getValueByName("ConnectionType")
+        if dbg:
+            print >> sys.stderr, connectiontype
+        print >> sys.stderr, "BEFORE"
+        if connectiontype.upper() == 'SSL':
+            self.server = poplib.POP3_SSL(server, port)
+        else:
+            tout = xConnectionContext.getValueByName("Timeout")
+            if dbg:
+                print >> sys.stderr, isinstance(tout,int)
+            if not isinstance(tout,int):
+                tout = _GLOBAL_DEFAULT_TIMEOUT
+            if dbg:
+                print >> sys.stderr, "Timeout: %s" % str(tout)
+            self.server = poplib.POP3(server, port, timeout=tout)
+        print >> sys.stderr, "AFTER"
+
+        user = xAuthenticator.getUserName().encode('ascii')
+        password = xAuthenticator.getPassword().encode('ascii')
+        if dbg:
+            print >> sys.stderr, 'Logging in, username of', user
+        self.server.user(user)
+        self.server.pass_(password)
+
+        for listener in self.listeners:
+            listener.connected(self.notify)
+    def disconnect(self):
+        if dbg:
+            print >> sys.stderr, "PyMailPOP3Service disconnect"
+        if self.server:
+            self.server.quit()
+            self.server = None
+        for listener in self.listeners:
+            listener.disconnected(self.notify)
+    def isConnected(self):
+        if dbg:
+            print >> sys.stderr, "PyMailPOP3Service isConnected"
+        return self.server != None
+    def getCurrentConnectionContext(self):
+        if dbg:
+            print >> sys.stderr, "PyMailPOP3Service getCurrentConnectionContext"
+        return self.connectioncontext
 
 class PyMailServiceProvider(unohelper.Base, XMailServiceProvider):
-	def __init__( self, ctx ):
-		if dbg:
-			print >> sys.stderr, "PyMailServiceProvider init"
-		self.ctx = ctx
-	def create(self, aType):
-		if dbg:
-			print >> sys.stderr, "PyMailServiceProvider create with", aType
-		if aType == SMTP:
-			return PyMailSMTPService(self.ctx);
-		elif aType == POP3:
-			return PyMailPOP3Service(self.ctx);
-		elif aType == IMAP:
-			return PyMailIMAPService(self.ctx);
-		else:
-			print >> sys.stderr, "PyMailServiceProvider, unknown TYPE", aType
+    def __init__( self, ctx ):
+        if dbg:
+            print >> sys.stderr, "PyMailServiceProvider init"
+        self.ctx = ctx
+    def create(self, aType):
+        if dbg:
+            print >> sys.stderr, "PyMailServiceProvider create with", aType
+        if aType == SMTP:
+            return PyMailSMTPService(self.ctx);
+        elif aType == POP3:
+            return PyMailPOP3Service(self.ctx);
+        elif aType == IMAP:
+            return PyMailIMAPService(self.ctx);
+        else:
+            print >> sys.stderr, "PyMailServiceProvider, unknown TYPE", aType
 
 class PyMailMessage(unohelper.Base, XMailMessage):
-	def __init__( self, ctx, sTo='', sFrom='', Subject='', Body=None, aMailAttachment=None ):
-		if dbg:
-			print >> sys.stderr, "PyMailMessage init"
-		self.ctx = ctx
-
-		self.recipients = [sTo]
-		self.ccrecipients = []
-		self.bccrecipients = []
-		self.aMailAttachments = []
-		if aMailAttachment != None:
-			self.aMailAttachments.append(aMailAttachment)
-
-		self.SenderName, self.SenderAddress = parseaddr(sFrom)
-		self.ReplyToAddress = sFrom
-		self.Subject = Subject
-		self.Body = Body
-		if dbg:
-			print >> sys.stderr, "post PyMailMessage init"
-	def addRecipient( self, recipient ):
-		if dbg:
-			print >> sys.stderr, "PyMailMessage.addRecipient", recipient
-		self.recipients.append(recipient)
-	def addCcRecipient( self, ccrecipient ):
-		if dbg:
-			print >> sys.stderr, "PyMailMessage.addCcRecipient", ccrecipient
-		self.ccrecipients.append(ccrecipient)
-	def addBccRecipient( self, bccrecipient ):
-		if dbg:
-			print >> sys.stderr, "PyMailMessage.addBccRecipient", bccrecipient
-		self.bccrecipients.append(bccrecipient)
-	def getRecipients( self ):
-		if dbg:
-			print >> sys.stderr, "PyMailMessage.getRecipients", self.recipients
-		return tuple(self.recipients)
-	def getCcRecipients( self ):
-		if dbg:
-			print >> sys.stderr, "PyMailMessage.getCcRecipients", self.ccrecipients
-		return tuple(self.ccrecipients)
-	def getBccRecipients( self ):
-		if dbg:
-			print >> sys.stderr, "PyMailMessage.getBccRecipients", self.bccrecipients
-		return tuple(self.bccrecipients)
-	def addAttachment( self, aMailAttachment ):
-		if dbg:
-			print >> sys.stderr, "PyMailMessage.addAttachment"
-		self.aMailAttachments.append(aMailAttachment)
-	def getAttachments( self ):
-		if dbg:
-			print >> sys.stderr, "PyMailMessage.getAttachments"
-		return tuple(self.aMailAttachments)
+    def __init__( self, ctx, sTo='', sFrom='', Subject='', Body=None, aMailAttachment=None ):
+        if dbg:
+            print >> sys.stderr, "PyMailMessage init"
+        self.ctx = ctx
+
+        self.recipients = [sTo]
+        self.ccrecipients = []
+        self.bccrecipients = []
+        self.aMailAttachments = []
+        if aMailAttachment != None:
+            self.aMailAttachments.append(aMailAttachment)
+
+        self.SenderName, self.SenderAddress = parseaddr(sFrom)
+        self.ReplyToAddress = sFrom
+        self.Subject = Subject
+        self.Body = Body
+        if dbg:
+            print >> sys.stderr, "post PyMailMessage init"
+    def addRecipient( self, recipient ):
+        if dbg:
+            print >> sys.stderr, "PyMailMessage.addRecipient", recipient
+        self.recipients.append(recipient)
+    def addCcRecipient( self, ccrecipient ):
+        if dbg:
+            print >> sys.stderr, "PyMailMessage.addCcRecipient", ccrecipient
+        self.ccrecipients.append(ccrecipient)
+    def addBccRecipient( self, bccrecipient ):
+        if dbg:
+            print >> sys.stderr, "PyMailMessage.addBccRecipient", bccrecipient
+        self.bccrecipients.append(bccrecipient)
+    def getRecipients( self ):
+        if dbg:
+            print >> sys.stderr, "PyMailMessage.getRecipients", self.recipients
+        return tuple(self.recipients)
+    def getCcRecipients( self ):
+        if dbg:
+            print >> sys.stderr, "PyMailMessage.getCcRecipients", self.ccrecipients
+        return tuple(self.ccrecipients)
+    def getBccRecipients( self ):
+        if dbg:
+            print >> sys.stderr, "PyMailMessage.getBccRecipients", self.bccrecipients
+        return tuple(self.bccrecipients)
+    def addAttachment( self, aMailAttachment ):
+        if dbg:
+            print >> sys.stderr, "PyMailMessage.addAttachment"
+        self.aMailAttachments.append(aMailAttachment)
+    def getAttachments( self ):
+        if dbg:
+            print >> sys.stderr, "PyMailMessage.getAttachments"
+        return tuple(self.aMailAttachments)
 
 
 # pythonloader looks for a static g_ImplementationHelper variable
 g_ImplementationHelper = unohelper.ImplementationHelper()
 g_ImplementationHelper.addImplementation( \
-	PyMailServiceProvider, "org.openoffice.pyuno.MailServiceProvider",
-		("com.sun.star.mail.MailServiceProvider",),)
+        PyMailServiceProvider, "org.openoffice.pyuno.MailServiceProvider",
+                ("com.sun.star.mail.MailServiceProvider",),)
 g_ImplementationHelper.addImplementation( \
-	PyMailMessage, "org.openoffice.pyuno.MailMessage",
-		("com.sun.star.mail.MailMessage",),)
+        PyMailMessage, "org.openoffice.pyuno.MailMessage",
+                ("com.sun.star.mail.MailMessage",),)

Modified: incubator/ooo/trunk/main/scripting/source/pyprov/officehelper.py
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/scripting/source/pyprov/officehelper.py?rev=1366506&r1=1366505&r2=1366506&view=diff
==============================================================================
--- incubator/ooo/trunk/main/scripting/source/pyprov/officehelper.py (original)
+++ incubator/ooo/trunk/main/scripting/source/pyprov/officehelper.py Fri Jul 27 19:16:57 2012
@@ -39,32 +39,32 @@ class BootstrapException(UnoException):
 def bootstrap():
     """Bootstrap OOo and PyUNO Runtime.
     The soffice process is started opening a named pipe of random name, then the local context is used
-	to access the pipe. This function directly returns the remote component context, from whereon you can
-	get the ServiceManager by calling getServiceManager() on the returned object.
-	"""
+        to access the pipe. This function directly returns the remote component context, from whereon you can
+        get the ServiceManager by calling getServiceManager() on the returned object.
+        """
     try:
-	# soffice script used on *ix, Mac; soffice.exe used on Windoof
+        # soffice script used on *ix, Mac; soffice.exe used on Windoof
         if "UNO_PATH" in os.environ:
             sOffice = os.environ["UNO_PATH"]
         else:
             sOffice = "" # lets hope for the best
         sOffice = os.path.join(sOffice, "soffice")
-        if platform.startswith("win"): 
+        if platform.startswith("win"):
             sOffice += ".exe"
-		
+
         # Generate a random pipe name.
         random.seed()
         sPipeName = "uno" + str(random.random())[2:]
-        
+
         # Start the office proces, don't check for exit status since an exception is caught anyway if the office terminates unexpectedly.
-        cmdArray = (sOffice, "-nologo", "-nodefault", "".join(["-accept=pipe,name=", sPipeName, ";urp;"]))        
+        cmdArray = (sOffice, "-nologo", "-nodefault", "".join(["-accept=pipe,name=", sPipeName, ";urp;"]))
         os.spawnv(os.P_NOWAIT, sOffice, cmdArray)
-			
+
         # ---------
 
         xLocalContext = uno.getComponentContext()
         resolver = xLocalContext.ServiceManager.createInstanceWithContext(
-			"com.sun.star.bridge.UnoUrlResolver", xLocalContext)
+                        "com.sun.star.bridge.UnoUrlResolver", xLocalContext)
         sConnect = "".join(["uno:pipe,name=", sPipeName, ";urp;StarOffice.ComponentContext"])
 
         # Wait until an office is started, but loop only nLoop times (can we do this better???)
@@ -80,7 +80,7 @@ def bootstrap():
                 sleep(0.5)  # Sleep 1/2 second.
 
     except BootstrapException:
-        raise     
+        raise
     except Exception, e:  # Any other exception
         raise BootstrapException("Caught exception " + str(e), None)
 

Modified: incubator/ooo/trunk/main/scripting/source/pyprov/pythonscript.py
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/scripting/source/pyprov/pythonscript.py?rev=1366506&r1=1366505&r2=1366506&view=diff
==============================================================================
--- incubator/ooo/trunk/main/scripting/source/pyprov/pythonscript.py (original)
+++ incubator/ooo/trunk/main/scripting/source/pyprov/pythonscript.py Fri Jul 27 19:16:57 2012
@@ -26,7 +26,7 @@ import sys
 import os
 import imp
 import time
-import compiler
+import ast
 
 class LogLevel:
     NONE = 0
@@ -72,18 +72,18 @@ def getLogTarget():
         except Exception,e:
             print "Exception during creation of pythonscript logfile: "+ lastException2String() + "\n, delagating log to stdout\n"
     return ret
-  
+
 class Logger(LogLevel):
     def __init__(self , target ):
         self.target = target
 
     def isDebugLevel( self ):
         return self.use >= self.DEBUG
-    
+
     def debug( self, msg ):
         if self.isDebugLevel():
             self.log( self.DEBUG, msg )
-    
+
     def isErrorLevel( self ):
         return self.use >= self.ERROR
 
@@ -145,9 +145,9 @@ def readTextFromStream( inputStream ):
         read,out = inputStream.readBytes( None , BLOCK_SIZE )
         code = code + out
         if read < BLOCK_SIZE:
-           break
+            break
     return code.value
-    
+
 def toIniName( str ):
     # TODO: what is the official way to get to know whether i am on the windows platform ?
     if( hasattr(sys , "dllhandle") ):
@@ -165,7 +165,7 @@ class MyUriHelper:
         { "share" : "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" +  toIniName( "bootstrap") + "::BaseInstallation}/share/Scripts/python" , \
           "share:uno_packages" : "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE/uno_packages", \
           "user" : "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + toIniName( "bootstrap") + "::UserInstallation}/user/Scripts/python" , \
-          "user:uno_packages" : "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/uno_packages" } 
+          "user:uno_packages" : "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/uno_packages" }
         self.m_uriRefFac = ctx.ServiceManager.createInstanceWithContext("com.sun.star.uri.UriReferenceFactory",ctx)
         if location.startswith( "vnd.sun.star.tdoc" ):
             self.m_baseUri = location + "/Scripts/python"
@@ -174,10 +174,10 @@ class MyUriHelper:
             self.m_baseUri = expandUri( self.s_UriMap[location] )
             self.m_scriptUriLocation = location
         log.isDebugLevel() and log.debug( "initialized urihelper with baseUri="+self.m_baseUri + ",m_scriptUriLocation="+self.m_scriptUriLocation )
-        
+
     def getRootStorageURI( self ):
         return self.m_baseUri
-    
+
     def getStorageURI( self, scriptURI ):
         return self.scriptURI2StorageUri(scriptURI)
 
@@ -195,7 +195,7 @@ class MyUriHelper:
               "?language=" + LANGUAGENAME + "&location=" + self.m_scriptUriLocation
         log.isDebugLevel() and log.debug( "converting storageURI="+storageURI + " to scriptURI=" + ret )
         return ret
-    
+
     def scriptURI2StorageUri( self, scriptURI ):
         try:
             myUri = self.m_uriRefFac.parse(scriptURI)
@@ -208,7 +208,7 @@ class MyUriHelper:
         except Exception, e:
             log.error( "error during converting scriptURI="+scriptURI + ": " + str(e))
             raise RuntimeException( "pythonscript:scriptURI2StorageUri: " + str(e), None )
-        
+
 
 class ModuleEntry:
     def __init__( self, lastRead, module ):
@@ -244,14 +244,14 @@ def checkForPythonPathBesideScript( url 
         if 1 == os.access( encfile(path), os.F_OK) and not path in sys.path:
             log.log( LogLevel.DEBUG, "adding " + path + " to sys.path" )
             sys.path.append( path )
-        
-    
+
+
 class ScriptContext(unohelper.Base):
     def __init__( self, ctx, doc, inv ):
         self.ctx = ctx
         self.doc = doc
         self.inv = inv
-       
+
    # XScriptContext
     def getDocument(self):
         if self.doc:
@@ -284,12 +284,12 @@ class ScriptContext(unohelper.Base):
 #            log.isDebugLevel() and log.debug("file " + url + " has changed, reloading")
 #        else:
 #            load = False
-#            
+#
 #    if load:
 #        log.isDebugLevel() and log.debug( "opening >" + url + "<" )
 #
 #        code = readTextFromStream( sfa.openFileRead( url ) )
-            
+
         # execute the module
 #        entry = ModuleEntry( lastRead, imp.new_module("ooo_script_framework") )
 #        entry.module.__dict__[GLOBAL_SCRIPTCONTEXT_NAME] = g_scriptContext
@@ -312,13 +312,13 @@ class ProviderContext:
     def getTransientPartFromUrl( self, url ):
         rest = url.replace( self.rootUrl , "",1 ).replace( "/","",1)
         return rest[0:rest.find("/")]
-    
+
     def getPackageNameFromUrl( self, url ):
         rest = url.replace( self.rootUrl , "",1 ).replace( "/","",1)
         start = rest.find("/") +1
         return rest[start:rest.find("/",start)]
-        
-        
+
+
     def removePackageByUrl( self, url ):
         items = self.mapPackageName2Path.items()
         for i in items:
@@ -336,20 +336,20 @@ class ProviderContext:
         else:
             package = Package( (url,), transientPart)
             self.mapPackageName2Path[ packageName ] = package
-    
+
     def isUrlInPackage( self, url ):
         values = self.mapPackageName2Path.values()
         for i in values:
-#	    print "checking " + url + " in " + str(i.pathes)
+#           print "checking " + url + " in " + str(i.pathes)
             if url in i.pathes:
-               return True
+                return True
 #        print "false"
         return False
-            
+
     def setPackageAttributes( self, mapPackageName2Path, rootUrl ):
         self.mapPackageName2Path = mapPackageName2Path
         self.rootUrl = rootUrl
-        
+
     def getPersistentUrlFromStorageUrl( self, url ):
         # package name is the second directory
         ret = url
@@ -374,27 +374,38 @@ class ProviderContext:
         checkForPythonPathBesideScript( url[0:url.rfind('/')] )
         src = ensureSourceState( src )
 
-        code = compiler.parse( src )
-
         allFuncs = []
-
-        if code == None:
-            return allFuncs
-        
         g_exportedScripts = []
-        for node in code.node.nodes:
-            if node.__class__.__name__ == 'Function':
-                allFuncs.append(node.name)
-            elif node.__class__.__name__ == 'Assign':
-                for assignee in node.nodes:
-                    if assignee.name == 'g_exportedScripts':
-                        for item in node.expr:
-                            if item.__class__.__name__ == 'Name':
-                                g_exportedScripts.append(item.name)
-                        return g_exportedScripts
 
+        a = ast.parse(src, url)
+
+        if isinstance(a, ast.Module):
+            for node in a.body:
+                if isinstance(node, ast.FunctionDef):
+                    allFuncs.append(node.name)
+                elif isinstance(node, ast.Assign):
+                    is_exported = False
+                    for subnode in node.targets:
+                        if isinstance(subnode, ast.Name) and \
+                            subnode.id == "g_exportedScripts":
+                            is_exported = True
+                            break
+                    if is_exported:
+                        value_node = node.value
+                        if isinstance(value_node, ast.List) or \
+                            isinstance(value_node, ast.Tuple):
+                            for elt in value_node.elts:
+                                if isinstance(elt, ast.Str):
+                                    g_exportedScripts.append(elt.s)
+                                elif isinstance(elt, ast.Name):
+                                    g_exportedScripts.append(elt.id)
+                        elif isinstance(value_node, ast.Str):
+                            g_exportedScripts.append(value_node.s)
+                        elif isinstance(value_node, ast.Name):
+                            g_exportedScripts.append(value_node.id)
+                        return g_exportedScripts
         return allFuncs
-    
+
     def getModuleByUrl( self, url ):
         entry =  self.modules.get(url)
         load = True
@@ -404,14 +415,14 @@ class ProviderContext:
                 log.isDebugLevel() and log.debug( "file " + url + " has changed, reloading" )
             else:
                 load = False
-                
+
         if load:
             log.isDebugLevel() and log.debug( "opening >" + url + "<" )
-            
+
             src = readTextFromStream( self.sfa.openFileRead( url ) )
             checkForPythonPathBesideScript( url[0:url.rfind('/')] )
-            src = ensureSourceState( src )            
-            
+            src = ensureSourceState( src )
+
             # execute the module
             entry = ModuleEntry( lastRead, imp.new_module("ooo_script_framework") )
             entry.module.__dict__[GLOBAL_SCRIPTCONTEXT_NAME] = self.scriptContext
@@ -426,14 +437,14 @@ class ProviderContext:
             self.modules[ url ] = entry
             log.isDebugLevel() and log.debug( "mapped " + url + " to " + str( entry.module ) )
         return  entry.module
-        
+
 #--------------------------------------------------
 def isScript( candidate ):
     ret = False
     if isinstance( candidate, type(isScript) ):
         ret = True
     return ret
-    
+
 #-------------------------------------------------------
 class ScriptBrowseNode( unohelper.Base, XBrowseNode , XPropertySet, XInvocation, XActionListener ):
     def __init__( self, provCtx, uri, fileName, funcName ):
@@ -441,7 +452,7 @@ class ScriptBrowseNode( unohelper.Base, 
         self.funcName = funcName
         self.provCtx = provCtx
         self.uri = uri
-        
+
     def getName( self ):
         return self.funcName
 
@@ -450,7 +461,7 @@ class ScriptBrowseNode( unohelper.Base, 
 
     def hasChildNodes(self):
         return False
-    
+
     def getType( self):
         return SCRIPT
 
@@ -462,19 +473,19 @@ class ScriptBrowseNode( unohelper.Base, 
                     self.provCtx.getPersistentUrlFromStorageUrl( self.uri + "$" + self.funcName ) )
             elif name == "Editable" and ENABLE_EDIT_DIALOG:
                 ret = not self.provCtx.sfa.isReadOnly( self.uri )
-        
+
             log.isDebugLevel() and log.debug( "ScriptBrowseNode.getPropertyValue called for " + name + ", returning " + str(ret) )
         except Exception,e:
             log.error( "ScriptBrowseNode.getPropertyValue error " + lastException2String())
             raise
-                                              
+
         return ret
     def setPropertyValue( self, name, value ):
         log.isDebugLevel() and log.debug( "ScriptBrowseNode.setPropertyValue called " + name + "=" +str(value ) )
     def getPropertySetInfo( self ):
         log.isDebugLevel() and log.debug( "ScriptBrowseNode.getPropertySetInfo called "  )
         return None
-               
+
     def getIntrospection( self ):
         return None
 
@@ -513,12 +524,12 @@ class ScriptBrowseNode( unohelper.Base, 
                 values = mod.__dict__.get( CALLABLE_CONTAINER_NAME , None )
                 if not values:
                     values = mod.__dict__.values()
-                    
+
                 for i in values:
                     if isScript( i ):
                         i()
                         break
-                    
+
             elif event.ActionCommand == "Save":
                 toWrite = uno.ByteSequence(
                     str(
@@ -536,7 +547,7 @@ class ScriptBrowseNode( unohelper.Base, 
         except Exception,e:
             # TODO: add an error box here !
             log.error( lastException2String() )
-            
+
 
     def setValue( self, name, value ):
         return None
@@ -550,7 +561,7 @@ class ScriptBrowseNode( unohelper.Base, 
     def hasProperty( self, name ):
         return False
 
-    
+
 #-------------------------------------------------------
 class FileBrowseNode( unohelper.Base, XBrowseNode ):
     def __init__( self, provCtx, uri , name ):
@@ -558,15 +569,15 @@ class FileBrowseNode( unohelper.Base, XB
         self.uri = uri
         self.name = name
         self.funcnames = None
-        
+
     def getName( self ):
         return self.name
- 
+
     def getChildNodes(self):
         ret = ()
         try:
             self.funcnames = self.provCtx.getFuncsByUrl( self.uri )
-            
+
             scriptNodeList = []
             for i in self.funcnames:
                 scriptNodeList.append(
@@ -585,11 +596,11 @@ class FileBrowseNode( unohelper.Base, XB
             return len(self.getChildNodes()) > 0
         except Exception, e:
             return False
-    
+
     def getType( self):
         return CONTAINER
 
-        
+
 
 class DirBrowseNode( unohelper.Base, XBrowseNode ):
     def __init__( self, provCtx, name, rootUrl ):
@@ -634,13 +645,13 @@ class DirBrowseNode( unohelper.Base, XBr
 class ManifestHandler( XDocumentHandler, unohelper.Base ):
     def __init__( self, rootUrl ):
         self.rootUrl = rootUrl
-        
+
     def startDocument( self ):
         self.urlList = []
-        
+
     def endDocument( self ):
         pass
-        
+
     def startElement( self , name, attlist):
         if name == "manifest:file-entry":
             if attlist.getValueByName( "manifest:media-type" ) == "application/vnd.sun.star.framework-script":
@@ -672,11 +683,11 @@ def isPyFileInPath( sfa, path ):
             break
     return ret
 
-# extracts META-INF directory from 
+# extracts META-INF directory from
 def getPathesFromPackage( rootUrl, sfa ):
     ret = ()
     try:
-        fileUrl = rootUrl + "/META-INF/manifest.xml" 
+        fileUrl = rootUrl + "/META-INF/manifest.xml"
         inputStream = sfa.openFileRead( fileUrl )
         parser = uno.getComponentContext().ServiceManager.createInstance( "com.sun.star.xml.sax.Parser" )
         handler = ManifestHandler( rootUrl )
@@ -691,7 +702,7 @@ def getPathesFromPackage( rootUrl, sfa )
         log.debug( "getPathesFromPackage " + fileUrl + " Exception: " +text )
         pass
     return ret
-    
+
 
 class Package:
     def __init__( self, pathes, transientPathElement ):
@@ -707,12 +718,12 @@ class DummyInteractionHandler( unohelper
 class DummyProgressHandler( unohelper.Base, XProgressHandler ):
     def __init__( self ):
         pass
-    
-    def push( self,status ): 
+
+    def push( self,status ):
         log.isDebugLevel() and log.debug( "pythonscript: DummyProgressHandler.push " + str( status ) )
-    def update( self,status ): 
+    def update( self,status ):
         log.isDebugLevel() and log.debug( "pythonscript: DummyProgressHandler.update " + str( status ) )
-    def pop( self ): 
+    def pop( self ):
         log.isDebugLevel() and log.debug( "pythonscript: DummyProgressHandler.push " + str( event ) )
 
 class CommandEnvironment(unohelper.Base, XCommandEnvironment):
@@ -744,12 +755,12 @@ def getModelFromDocUrl(ctx, url):
     p = Property()
     p.Name = "DocumentModel"
     p.Handle = -1
-    
+
     c = Command()
     c.Handle = -1
     c.Name = "getPropertyValues"
     c.Argument = uno.Any("[]com.sun.star.beans.Property", (p,))
-    
+
     env = CommandEnvironment()
     try:
         ret = content.execute(c, 0, env)
@@ -850,7 +861,7 @@ class PythonScript( unohelper.Base, XScr
             # some people may beat me up for modifying the exception text,
             # but otherwise office just shows
             # the type name and message text with no more information,
-            # this is really bad for most users. 
+            # this is really bad for most users.
             e.Message = e.Message + " (" + complete + ")"
             raise
         except Exception,e:
@@ -872,7 +883,7 @@ def expandUri(  uri ):
     if uri.startswith( "file:" ):
         uri = uno.absolutize("",uri)   # necessary to get rid of .. in uri
     return uri
-    
+
 #--------------------------------------------------------------
 class PythonScriptProvider( unohelper.Base, XBrowseNode, XScriptProvider, XNameContainer):
     def __init__( self, ctx, *args ):
@@ -897,7 +908,7 @@ class PythonScriptProvider( unohelper.Ba
             try:
                 doc = inv.ScriptContainer
                 content = ctx.getServiceManager().createInstanceWithContext(
-                    "com.sun.star.frame.TransientDocumentsDocumentContentFactory", 
+                    "com.sun.star.frame.TransientDocumentsDocumentContentFactory",
                     ctx).createDocumentContent(doc)
                 storageType = content.getIdentifier().getContentIdentifier()
             except Exception, e:
@@ -911,7 +922,7 @@ class PythonScriptProvider( unohelper.Ba
 #                "com.sun.star.script.provider.ScriptURIHelper", (LANGUAGENAME, storageType), ctx)
             urlHelper = MyUriHelper( ctx, storageType )
             log.isDebugLevel() and log.debug( "got urlHelper " + str( urlHelper ) )
-        
+
             rootUrl = expandUri( urlHelper.getRootStorageURI() )
             log.isDebugLevel() and log.debug( storageType + " transformed to " + rootUrl )
 
@@ -929,7 +940,7 @@ class PythonScriptProvider( unohelper.Ba
                 self.dirBrowseNode = PackageBrowseNode( self.provCtx, LANGUAGENAME, rootUrl )
             else:
                 self.dirBrowseNode = DirBrowseNode( self.provCtx, LANGUAGENAME, rootUrl )
-            
+
         except Exception, e:
             text = lastException2String()
             log.debug( "PythonScriptProvider could not be instantiated because of : " + text )
@@ -939,7 +950,7 @@ class PythonScriptProvider( unohelper.Ba
         return self.dirBrowseNode.getName()
 
     def getChildNodes( self ):
-        return self.dirBrowseNode.getChildNodes()    
+        return self.dirBrowseNode.getChildNodes()
 
     def hasChildNodes( self ):
         return self.dirBrowseNode.hasChildNodes()
@@ -949,22 +960,22 @@ class PythonScriptProvider( unohelper.Ba
 
     def getScript( self, uri ):
         log.debug( "DirBrowseNode getScript " + uri + " invoked" )
-        
+
         raise IllegalArgumentException( "DirBrowseNode couldn't instantiate script " + uri , self , 0 )
 
     def getScript( self, scriptUri ):
         try:
             log.isDebugLevel() and log.debug( "getScript " + scriptUri + " invoked")
-            
+
             storageUri = self.provCtx.getStorageUrlFromPersistentUrl(
                 self.provCtx.uriHelper.getStorageURI(scriptUri) );
             log.isDebugLevel() and log.debug( "getScript: storageUri = " + storageUri)
             fileUri = storageUri[0:storageUri.find( "$" )]
-            funcName = storageUri[storageUri.find( "$" )+1:len(storageUri)]        
-            
+            funcName = storageUri[storageUri.find( "$" )+1:len(storageUri)]
+
             mod = self.provCtx.getModuleByUrl( fileUri )
             log.isDebugLevel() and log.debug( " got mod " + str(mod) )
-            
+
             func = mod.__dict__[ funcName ]
 
             log.isDebugLevel() and log.debug( "got func " + str( func ) )
@@ -973,7 +984,7 @@ class PythonScriptProvider( unohelper.Ba
             text = lastException2String()
             log.error( text )
             raise ScriptFrameworkErrorException( text, self, scriptUri, LANGUAGENAME, 0 )
-        
+
 
     # XServiceInfo
     def getSupportedServices( self ):
@@ -989,11 +1000,11 @@ class PythonScriptProvider( unohelper.Ba
         log.debug( "getByName called" + str( name ))
         return None
 
-        
+
     def getElementNames( self ):
         log.debug( "getElementNames called")
         return ()
-    
+
     def hasByName( self, name ):
         try:
             log.debug( "hasByName called " + str( name ))
@@ -1015,7 +1026,7 @@ class PythonScriptProvider( unohelper.Ba
             log.debug( "removeByName unknown uri " + str( name ) + ", ignoring" )
             raise NoSuchElementException( uri + "is not in package" , self )
         log.debug( "removeByName called" + str( uri ) + " successful" )
-        
+
     def insertByName( self, name, value ):
         log.debug( "insertByName called " + str( name ) + " " + str( value ))
         uri = expandUri( name )
@@ -1036,16 +1047,15 @@ class PythonScriptProvider( unohelper.Ba
     def getElementType( self ):
         log.debug( "getElementType called" )
         return uno.getTypeByName( "void" )
-    
+
     def hasElements( self ):
         log.debug( "hasElements got called")
         return False
-    
+
 g_ImplementationHelper.addImplementation( \
-	PythonScriptProvider,g_implName, \
+        PythonScriptProvider,g_implName, \
     ("com.sun.star.script.provider.LanguageScriptProvider",
      "com.sun.star.script.provider.ScriptProviderFor"+ LANGUAGENAME,),)
 
 
 log.debug( "pythonscript finished intializing" )
-



Mime
View raw message