diff decoupage/web.py @ 107:450aff4c97e3

py35 compat
author Jeff Hammel <k0scist@gmail.com>
date Fri, 31 Mar 2017 17:06:59 -0700
parents 747c7e337c56
children 8298abd49954
line wrap: on
line diff
--- a/decoupage/web.py	Fri Mar 31 16:38:02 2017 -0700
+++ b/decoupage/web.py	Fri Mar 31 17:06:59 2017 -0700
@@ -103,10 +103,9 @@
             try:
                 _cls = _format.load()
                 _instance = _cls(self, **format_args.get(_format.name, {}))
-            except Exception, e:
+            except Exception as e:
                 # record the error, but persist
-                print >> sys.stderr, "Couldn't load format: %s" % _format
-                print >> sys.stderr, e
+                sys.stderr.write("Couldn't load format: {}\n{}\n".format(_format, e))
                 continue
             self.formats[_format.name] = _instance
 
@@ -118,10 +117,9 @@
                 template_dir = resource_filename(formatter.module_name, 'templates')
                 if template_dir not in self.template_directories and os.path.isdir(template_dir):
                     self.template_directories.append(template_dir)
-            except Exception, e:
+            except Exception as e:
                 # record the error, but persist
-                print >> sys.stderr, "Couldn't load formatter: %s" % formatter
-                print >> sys.stderr, e
+                sys.stderr.write("Couldn't load formatter: {}\n{}\n".format(formatter, e))
                 continue
             self.formatters[formatter.name] = _formatter
 
@@ -247,9 +245,9 @@
         try:
             template = self.loader.load(template)
             res = template.generate(**data).render('html', doctype='html')
-        except (TemplateError, TemplateSyntaxError, TemplateNotFound), e:
+        except (TemplateError, TemplateSyntaxError, TemplateNotFound) as e:
             if local_index:
-                print repr(e)
+                print (repr(e))
                 return self.fileserver(local_index)
             raise
         finally: