From 0fe5b9553af54fd31279bc23466fd80d96ee0f9e Mon Sep 17 00:00:00 2001 From: endorphant Date: Tue, 31 May 2016 15:03:34 -0400 Subject: [PATCH] breaking out nopub into its own function --- bin/_ttbp.py | 6 +++++- bin/core.py | 22 +++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/bin/_ttbp.py b/bin/_ttbp.py index 1ca55eb..5ed7cb0 100644 --- a/bin/_ttbp.py +++ b/bin/_ttbp.py @@ -483,10 +483,13 @@ def view_feels(townie): ''' filenames = [] + showpub = False if townie == USER: entryDir = DATA owner = "your" + if core.publishing(): + showpub = True else: owner = "~"+townie+"'s" entryDir = os.path.join("/home", townie, ".ttbp", "entries") @@ -497,8 +500,9 @@ def view_feels(townie): if len(filenames) > 0: entries = [] + pub = "" for entry in metas: - entries.append(""+entry[4]+" ("+p.no("word", entry[2])+") ") + entries.append(""+entry[4]+" ("+p.no("word", entry[2])+") "+"\t"+pub) return list_entries(metas, entries, owner+" recorded feels, listed by date: \n") else: diff --git a/bin/core.py b/bin/core.py index d84dc08..0926ec9 100644 --- a/bin/core.py +++ b/bin/core.py @@ -79,15 +79,10 @@ def load_files(): global FILES - exclude = [] - - if os.path.isfile(NOPUB): - for line in open(NOPUB, "r"): - exclude.append(line.rstrip()) - FILES = [] + for filename in os.listdir(DATA): - if filename in exclude: + if nopub(filename): continue filename = os.path.join(DATA, filename) if os.path.isfile(filename) and valid(filename): @@ -395,6 +390,19 @@ def www_neighbors(): write_global_feed(sortedUsers) +def nopub(filename): + ''' + checks to see if given filename is in user's NOPUB + ''' + + exclude = [] + + if os.path.isfile(NOPUB): + for line in open(NOPUB, "r"): + exclude.append(line.rstrip()) + + return os.path.basename(filename) in exclude + ############# ############# #############