diff options
| -rw-r--r-- | BibTeX.py | 10 | ||||
| -rw-r--r-- | config.py | 3 |
2 files changed, 11 insertions, 2 deletions
@@ -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): @@ -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 |
