commit 9bef0bfbe6a6edd233b80760b77887cbd5cf80b1
parent 673f3e9a6bf8391be2ddad3acb8c5880d7002add
Author: Nick Mathewson <nickm@torproject.org>
Date: Thu, 7 Dec 2006 04:41:08 +0000
r11440@Kushana: nickm | 2006-12-06 23:40:44 -0500
Add a REQUIRE_KEY option to the configuration. This way, we can build a "big bibliography" and a "selected readings" from one .bib file.
svn:r194
Diffstat:
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/BibTeX.py b/BibTeX.py
@@ -84,8 +84,14 @@ class BibTeX:
ent.entries.update(cr.entries)
ent.resolve()
newEntries = []
+ rk = config.REQUIRE_KEY
+ if rk is None:
+ # hack: if no key is required, require "title", since every
+ # entry will have a title.
+ rk = "title"
+
for ent in self.entries:
- if ent.type in config.OMIT_ENTRIES:
+ if ent.type in config.OMIT_ENTRIES or not ent.has_key(rk):
del self.byKey[ent.key]
else:
newEntries.append(ent)
@@ -258,6 +264,8 @@ class BibTeXEntry:
self.entries = entries # Map from key to value.
def get(self, k, v=None):
return self.entries.get(k,v)
+ def has_key(self, k):
+ return self.entries.has_key(k)
def __getitem__(self, k):
return self.entries[k]
def __setitem__(self, k, v):
diff --git a/anonbib.cfg b/anonbib.cfg
@@ -13,6 +13,13 @@ CACHE_DIR = "cache"
# different Apache permission on different directories.
CACHE_SECTIONS = [ ]
+# Only include entries that have this key. Used to generate multiple
+# bibliographies from the same source.
+#
+#example: REQUIRE_KEY = "www_selected"
+#
+REQUIRE_KEY = None
+
# Timeout when downloading from a server while caching, in seconds.
DOWNLOAD_CONNECT_TIMEOUT = 15
diff --git a/config.py b/config.py
@@ -6,7 +6,8 @@ _KEYS = [ "ALPHABETIZE_AUTHOR_AS","AUTHOR_URLS","CACHE_DIR","CACHE_SECTIONS",
"COLLAPSE_AUTHORS",
"DOWNLOAD_CONNECT_TIMEOUT","INITIAL_STRINGS",
"MASTER_BIB", "NO_COLLAPSE_AUTHORS", "OMIT_ENTRIES",
- "OUTPUT_DIR", "TEMPLATE_FILE", "BIBTEX_TEMPLATE_FILE" ]
+ "OUTPUT_DIR", "TEMPLATE_FILE", "BIBTEX_TEMPLATE_FILE",
+ "REQUIRE_KEY" ]
for _k in _KEYS:
globals()[_k]=None