ignore mal-formed input lines

sort usernames by default
This commit is contained in:
lars 2010-06-05 01:22:20 +00:00
parent 6295daf7f7
commit 53d561e65d

View file

@ -55,8 +55,9 @@ class HtpasswdFile:
"""
self.entries = {}
for line in open(self.filename, 'r').readlines():
username, pwhash = line.split(':', 1)
self.entries[username] = pwhash
if ":" in line:
username, pwhash = line.split(':', 1)
self.entries[username] = pwhash
def save(self):
"""Write the htpasswd file to disk
@ -96,5 +97,7 @@ class HtpasswdFile:
self.entries.pop(username)
def get_usernames(self):
return self.entries.keys()
names = self.entries.keys()
names.sort()
return names