updates for python3
[yourule] / yourule.py
index 0d8adbc8a281063ffefc8052be6d7c2750f54022..ebd85cb99de42038d9897522511d93ab2d832d2c 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # YouRule: Onscreen Ruler Generator
 #
@@ -19,7 +19,7 @@
 # <http://http://www.affero.org/oagpl.html>.
 
 
-from __future__ import division
+
 import web
 import sys, os, re
 from storm.locals import *
@@ -28,7 +28,7 @@ from storm.locals import *
 sys.path.append(os.path.dirname(__file__))
 from svgruler import SVGRuler
 
-from jinja import Environment, FileSystemLoader
+from jinja2 import Environment, FileSystemLoader
 jinja_env = Environment('<%', '%>', '<%=', '%>', '<%#', '%>', 
                         loader=FileSystemLoader(os.path.dirname(__file__) + "/templates/"))
 
@@ -69,11 +69,11 @@ class Ruler(object):
     def __init__(self, **kw):
         self.pixel_width = float(kw['pixel_width'])
         self.unit_width = float(kw['unit_width'])
-        self.units = unicode(kw['units'])
-        if kw.has_key('model'):
-            self.model = unicode(kw['model'])
+        self.units = str(kw['units'])
+        if 'model' in kw:
+            self.model = str(kw['model'])
         else:
-            self.model = u''
+            self.model = ''
 
     def cm_width(self):
         if self.units == 'centimeters':
@@ -115,7 +115,7 @@ class index:
 
 class show_ruler:
     def GET(self, ruler_url, ext):
-        if web.input().has_key('fromgallery'):
+        if 'fromgallery' in web.input():
             fromgallery = True
         else:
             fromgallery = False

Benjamin Mako Hill || Want to submit a patch?