From 9939c56195f2d132af48f162b34863e38fb69fe8 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 7 Dec 2006 04:41:08 +0000 Subject: 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 --- BibTeX.py | 10 +++++++++- config.py | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/BibTeX.py b/BibTeX.py index 4b635c6..451c243 100644 --- 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/config.py b/config.py index 9413d25..3486243 100644 --- 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 -- cgit v1.2.3-70-g09d2