changeset 133:ce478807848e default tip

py3
author Jeff Hammel <k0scist@gmail.com>
date Mon, 28 Dec 2020 21:18:19 +0000
parents bda88f101ba9
children
files bitsyblog/user.py
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/bitsyblog/user.py	Mon Dec 28 20:49:32 2020 +0000
+++ b/bitsyblog/user.py	Mon Dec 28 21:18:19 2020 +0000
@@ -83,11 +83,11 @@
     def secret(self, user):
         secretfile = self.home(user, '.secret')
         if os.path.exists(secretfile):
-            secret = int(file(secretfile).read().strip())
+            secret = int(open(secretfile).read().strip())
         else:
             secret = random.randint(1024, 1024**4)
-            secretfile = file(secretfile, 'w')
-            print >> secretfile, secret
+            with open(secretfile, 'w') as secretfile:
+                secretfile.write('{}\n'.format(secret))
         return secret
 
     def preferences_file(self, user):
@@ -103,9 +103,9 @@
                 css_files.insert(0, css_files.pop(index))
             except ValueError:
                 pass
-        retval = [ dict(filename=i, name=i.rsplit('.css',1)[0],
-                        css=file(os.path.join(css_dir, i)).read())
-                   for i in css_files ]
+        retval = [dict(filename=i, name=i.rsplit('.css',1)[0],
+                       css=open(os.path.join(css_dir, i)).read())
+                  for i in css_files]
         return retval