Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.pyc
build/
3 changes: 3 additions & 0 deletions crosstex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ def __init__(self, xtx_path=None):
def no_pages(self):
self._flags.add('no-pages')

def no_address(self):
self._flags.add('no-address')

def add_in(self):
self._flags.add('add-in')

Expand Down
4 changes: 4 additions & 0 deletions crosstex/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ def __call__(self, parser, args, values, option_string=None):
help='Write the bibliography to the specified output file.')
parser.add_argument('--no-pages', action='store_const', const=True, default=False,
help='Skip pages.')
parser.add_argument('--no-address', action='store_const', const=True, default=False,
help='Skip address.')
parser.add_argument('--add-in', action='store_const', const=True, default=False,
help='Add "In" for articles.')
parser.add_argument('--add-proc', dest='add_proc',
Expand All @@ -155,6 +157,8 @@ def main(argv):
xtx.set_titlecase(args.titlecase)
if args.no_pages:
xtx.no_pages()
if args.no_address:
xtx.no_address()
if args.add_in:
xtx.add_in()
if args.add_proc == 'proc':
Expand Down
10 changes: 9 additions & 1 deletion crosstex/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,15 @@ def _parse_ext_xtx(self, path):
logger.debug('Processing database %s.' % path)
db = XTXFileInfo()
stream = open(path)
contents = stream.read().decode('utf8')
coded = stream.read()
try:
contents = coded.decode('utf8')
except UnicodeDecodeError:
try:
contents = coded.decode('utf16')
except UnicodeDecodeError:
print coded
contents = coded.decode()
if contents:
lexer = ply.lex.lex(reflags=re.UNICODE)
lexer.path = path
Expand Down
Loading