Here my version, I used though more simple format of username,password and standard lowercase Python function names:
import time
import os
import hashlib
FILENAME = 'users/users.txt'
def user_creation():
while True:
try:
userfile = open(FILENAME, 'r')
except IOError:
# create file if it does not exist
path = os.path.dirname(os.path.abspath(FILENAME))
try:
# create directories which do not exist
os.makedirs(path)
except:
# directory existed
pass
userfile = open(FILENAME, 'w')
else:
user = raw_input("Please enter your username: ").lower()
# all usernames are prepared in lowercase at input
if "%s," % user in userfile.read():
print 'Taken password, try another username'
else:
passwort = raw_input("Enter your password: ")
#hashing password and writing
passwort = hashlib.sha224(passwort).hexdigest()
open(FILENAME, 'a').write("%s,%s\n" % (user, passwort))
# success, return
return
user_creation()