summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.py45
1 files changed, 29 insertions, 16 deletions
diff --git a/build.py b/build.py
index a9b328b..60f4510 100644
--- a/build.py
+++ b/build.py
@@ -46,13 +46,23 @@ def build_archive(jenv, entries):
f.write(rendered)
-def entry_exists(entry):
- path = 'entries/{}.rst'.format(entry['file'])
- if not os.path.isfile(path):
- print('''Source file '{}' for entry '{}' does not exist. Skipping.'''
- .format(path, entry['title']))
- return False
- return True
+def split_entries(entries):
+ published = []
+ unpublished = []
+
+ for entry in entries:
+ path = 'entries/{}.rst'.format(entry['file'])
+ if not os.path.isfile(path):
+ print('''Source file '{}' for entry '{}' does not exist. Skipping.'''
+ .format(path, entry['title']))
+ continue
+
+ if entry.get('published', "True") == "True":
+ published.append(entry)
+ else:
+ unpublished.append(entry)
+
+ return (published, unpublished)
if __name__ == '__main__':
@@ -63,21 +73,24 @@ if __name__ == '__main__':
with open('entries.json') as f:
entries = json.load(f)
- entries = list(filter(entry_exists, entries))
+ published, unpublished = split_entries(entries)
+
+ for entry in unpublished:
+ build_entry(jenv, entry)
- for index, entry in enumerate(entries):
+ for index, entry in enumerate(published):
older = None
newer = None
if index > 0:
- older = entries[index-1]
- if index < len(entries) - 1:
- newer = entries[index+1]
+ older = published[index-1]
+ if index < len(published) - 1:
+ newer = published[index+1]
build_entry(jenv, entry, older, newer)
- if len(entries) > 1:
- build_index(jenv, entries[-1], entries[-2])
+ if len(published) > 1:
+ build_index(jenv, published[-1], published[-2])
else:
- build_index(jenv, entries[-1], None)
+ build_index(jenv, published[-1], None)
- build_archive(jenv, entries)
+ build_archive(jenv, published)