diff options
| author | Nick Mathewson <nickm@torproject.org> | 2003-05-23 02:59:06 +0000 |
|---|---|---|
| committer | Nick Mathewson <nickm@torproject.org> | 2003-05-23 02:59:06 +0000 |
| commit | 5255afb72d1e7105fbb3cce9dbe27f4836aa48b9 (patch) | |
| tree | 3b6549bdcbb40a3e41873d0ae4286f2ba644f8cb /BibTeX.py | |
| parent | 9f98a5610bfe7b40d9ffe751dbf87a851d823f29 (diff) | |
| download | anonbib-5255afb72d1e7105fbb3cce9dbe27f4836aa48b9.tar.gz | |
Freak out properly when our input isnt ascii
svn:r33
Diffstat (limited to 'BibTeX.py')
| -rw-r--r-- | BibTeX.py | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -240,9 +240,12 @@ class BibTeXEntry: d.append("%%%%% ERROR: Missing field\n") d.append("%% %s = {?????},\n"%f) continue + np = v.translate(ALLCHARS, PRINTINGCHARS) + if np: + d.append("%%%%% "+("ERROR: Non-ASCII characters: '%r'\n"%np)) d.append(" ") if invStrings.has_key(v): - s = "%s = %s," %(f, invStrings[v]) + s = "%s = %s,\n" %(f, invStrings[v]) else: s = "%s = {%s},\n" % (f, v) d.append(_split(s,width,indent)) @@ -269,7 +272,6 @@ class BibTeXEntry: print e return not errs - def _check(self): errs = [] if self.type == 'inproceedings': @@ -299,6 +301,9 @@ class BibTeXEntry: errs.append("ERROR: %s's booktitle doesn't start with 'Proceedings'" % self.key) for field, value in self.entries.items(): + if value.translate(ALLCHARS, PRINTINGCHARS): + errs.append("ERROR: %s.%s has non-ASCII characters"%( + self.key, field)) if field.startswith("www_") and field not in WWW_FIELDS: errs.append("ERROR: unknown www field %s"% field) if value.strip()[-1:] == '.' and \ @@ -724,6 +729,7 @@ def parseAuthor(s): return parsedAuthors ALLCHARS = "".join(map(chr,range(256))) +PRINTINGCHARS = "\t\n\r"+"".join(map(chr,range(32, 127))) LC_CHARS = "abcdefghijklmnopqrstuvwxyz" SV_DELCHARS = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" |
