changeset 120:7306d47d2667

py3
author Jeff Hammel <k0scist@gmail.com>
date Tue, 03 Nov 2020 14:46:51 -0800 (2020-11-03)
parents ff44e92fe93f
children 188e501c00ff
files bitsyblog/user.py
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/bitsyblog/user.py	Tue Nov 03 14:43:01 2020 -0800
+++ b/bitsyblog/user.py	Tue Nov 03 14:46:51 2020 -0800
@@ -6,9 +6,10 @@
 import random
 import settings
 import shutil
-from roles import roles
+from .roles import roles
 from webob import exc
 
+
 class BitsyUser(object):
     """interface class for a bitsyblog user"""
     settings = {}
@@ -131,8 +132,8 @@
         # create user directory
         home = self.home(name)
         os.mkdir(home)
-        pw_file = file(self.pw_file(name), 'w')
-        print >> pw_file, password
+        with open(self.pw_file(name), 'w') as pw_file:
+            pw_file.write(password)
 
         # setup entries structure for blog
         entries = os.path.join(home, 'entries')
@@ -147,8 +148,8 @@
                         os.path.join(css_dir, 'default.css'))
 
 
-    def users(self):
-        ignores = set(['.svn'])
+    def users(self, ignores=()):
+
         for user in os.listdir(self.directory):
             # ensure integrity of user folder
             if user in ignores:
@@ -165,10 +166,11 @@
 
     def settings(self, name):
         """returns a dictionary of user preferences from a file"""
+
         filename = self.home(name, 'preferences.txt')
         prefs = {}
         if os.path.exists(filename):
-            prefs = file(filename).read().split('\n')
+            prefs = open(filename).read().split('\n')
             prefs = [ i for i in prefs if i.strip() ]
             prefs = [ [ j.strip() for j in i.split(':', 1) ]
                       for i in prefs if ':' in i]