[Twisted-Python] clean up app.getApplication

Paul Boehm paul at soniq.net
Sat Sep 27 16:17:00 MDT 2003


i was doing something else, couldn't quite understand the code at first
(where does the listcomp begin, where does it end?), so here's a more
explicit version:

Index: app.py
===================================================================
RCS file: /cvs/Twisted/twisted/application/app.py,v
retrieving revision 1.3
diff -u -r1.3 app.py
--- app.py  21 Sep 2003 01:07:23 -0000  1.3
+++ app.py  27 Sep 2003 22:16:16 -0000
@@ -81,9 +81,14 @@
         return None
 
 def getApplication(config, passphrase):
-    s = [(config[t], t)
-           for t in ['python', 'xml', 'source', 'file'] if config[t]][0]
-    filename, style = s[0], {'file':'pickle'}.get(s[1],s[1])
+    for t in ['python', 'xml', 'source', 'file', 'tapdir', None]:
+        style = t
+        filename = config[style]
+        if filename:
+            break
+    if style == 'file':
+        style = 'pickle'
+
     try:
         log.msg("Loading %s..." % filename)
         application = service.loadApplication(filename, style, passphrase)





More information about the Twisted-Python mailing list