-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: 'NoneType' object has no attribute 'group' #12
Comments
Hi, this is a result of the regex search not finding any linked bibliography files in the tex file. This can be due to other commands being used to specify the bibliography files, e.g., One way out is to specify to use the BBL file directly using the The (in my opinion) better alternative is to fix the @@ -478,8 +478,9 @@ def read_bibfile(oldnew):
'''Reads contents of bibtex files'''
# get bibtex file
- bibarg = find_bibliography_arg(getattr(FileContents, 'tex_' + oldnew))
- find_bibfiles(bibarg, oldnew)
+ bibargs = find_bibliography_args(getattr(FileContents, 'tex_' + oldnew))
+ for bibarg in bibargs:
+ find_bibfiles(bibarg, oldnew)
bibfiles = getattr(Files, 'bib_' + oldnew + '_path')
# read bibtex files
@@ -489,13 +490,16 @@ def read_bibfile(oldnew):
getattr(FileContents, 'bib_' + oldnew).append(f.read())
-def find_bibliography_arg(s):
+def find_bibliography_args(s):
'''Looks through string for \bibliography{} command and retrieves the argument'''
+ bibfiles = []
log.debug('searching for \\bibliography{} entry in tex file')
- bibfile = re.search(r'$[^%]*\\bibliography\s*{(.*?)}', s, flags=re.M).group(1)
- log.debug('bibliography argument found: %s', bibfile)
- return bibfile
+ bibfiles.extend(re.findall(r'^\s*\\bibliography\s*{(.*?)}', s, flags=re.M))
+ log.debug('searching for \\addbibresource{} entries in tex file')
+ bibfiles.extend(re.findall(r'^\s*\\addbibresource\s*{(.*?)}', s, flags=re.M))
+ log.debug('bibliography arguments found: %s', str(bibfiles))
+ return bibfiles Hope that helps! Happy to submit a PR if it's welcome @twilsonco @cmeeren . Cheers |
Thanks @tobiscode, I agree the best approach is to modify the source to check for all applicable bibliography commands. I’ll be using this tool again for some paper revisions soon, and will update things then. A PR would be welcome since you already have the changes working. Thanks! |
Hi,
I got this error, maybe related to parse error.
Do you know how to fix this?
The text was updated successfully, but these errors were encountered: