list user count and whitespace correction

master
endorphant 2016-05-03 13:20:28 -04:00
parent 0ed42304c8
commit 06d6609f80
1 changed files with 12 additions and 11 deletions

View File

@ -230,8 +230,13 @@ def main_menu():
today = time.strftime("%Y%m%d") today = time.strftime("%Y%m%d")
write_entry(os.path.join(DATA, today+".txt")) write_entry(os.path.join(DATA, today+".txt"))
elif choice == '1': elif choice == '1':
redraw("the following users are publishing on ttbp:\n\n") users = []
view_neighbors()
for townie in os.listdir("/home"):
if os.path.exists(os.path.join("/home", townie, ".ttbp", "config", "ttbprc")):
users.append(townie)
redraw("the following "+p.no("user", len(users))+" are publishing on ttbp:\n\n")
view_neighbors(users)
elif choice == '2': elif choice == '2':
pretty_settings = "\n\ttext editor:\t" +SETTINGS["editor"] pretty_settings = "\n\ttext editor:\t" +SETTINGS["editor"]
pretty_settings += "\n\tpublish dir:\t" +os.path.join(PUBLIC, SETTINGS["publish dir"]) pretty_settings += "\n\tpublish dir:\t" +os.path.join(PUBLIC, SETTINGS["publish dir"])
@ -300,14 +305,7 @@ def send_feedback(subject="none", mailbox=os.path.join(FEEDBACK, USER+"-"+time.s
return "mail sent. thanks for writing! i'll try to respond to you soon." return "mail sent. thanks for writing! i'll try to respond to you soon."
def view_neighbors(): def view_neighbors(users):
# TODO: rewrite this so you don't have to traverse a second list??
users = []
for townie in os.listdir("/home"):
if os.path.exists(os.path.join("/home", townie, ".ttbp", "config", "ttbprc")):
users.append(townie)
for user in users: for user in users:
userRC = json.load(open(os.path.join("/home", user, ".ttbp", "config", "ttbprc"))) userRC = json.load(open(os.path.join("/home", user, ".ttbp", "config", "ttbprc")))
@ -316,10 +314,13 @@ def view_neighbors():
for filename in os.listdir(os.path.join("/home", user, ".ttbp", "entries")): for filename in os.listdir(os.path.join("/home", user, ".ttbp", "entries")):
if os.path.splitext(filename)[1] == ".txt" and len(os.path.splitext(filename)[0]) == 8: if os.path.splitext(filename)[1] == ".txt" and len(os.path.splitext(filename)[0]) == 8:
count += 1 count += 1
pad = ""
if len(user) < 4:
pad = "\t"
user = "~"+user user = "~"+user
if len(user) < 8: if len(user) < 8:
user += "\t" user += "\t"
print("\t"+user+"\t at "+url+"\t("+p.no("entry", count)+")") print("\t"+user+"\t at "+url+pad+"\t("+p.no("entry", count)+")")
raw_input("\n\npress <enter> to go back home.\n\n") raw_input("\n\npress <enter> to go back home.\n\n")
redraw() redraw()