Skip to content

Commit

Permalink
ruff: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
DonHaul committed Oct 3, 2024
1 parent ce53808 commit e04e160
Show file tree
Hide file tree
Showing 18 changed files with 476 additions and 374 deletions.
106 changes: 0 additions & 106 deletions Untitled.ipynb

This file was deleted.

3 changes: 2 additions & 1 deletion refextract/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def extract_journal_info(args):
return make_response(
jsonify(
{
"message": f"Can not extract publication info data. Reason: {str(e)}"
"message":
f"Can not extract publication info data. Reason: {str(e)}"
}
),
500,
Expand Down
181 changes: 108 additions & 73 deletions refextract/authors/regexs.py

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion refextract/documents/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
re_space_closing_square_bracket = re.compile(r'\s\]', re.UNICODE)
re_opening_square_bracket_space = re.compile(r'\[\s', re.UNICODE)
re_hyphens = re.compile(
br'(\\255|\u02D7|\u0335|\u0336|\u2212|\u002D|\uFE63|\uFF0D)'.decode('raw_unicode_escape'), re.UNICODE)
br'(\\255|\u02D7|\u0335|\u0336|\u2212|\u002D|\uFE63|\uFF0D)'
.decode('raw_unicode_escape'), re.UNICODE)
re_multiple_space = re.compile(r'\s{2,}', re.UNICODE)

re_group_captured_multiple_space = re.compile(r'(\s{2,})', re.UNICODE)
Expand Down
16 changes: 11 additions & 5 deletions refextract/references/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def extract_references_from_url(url, headers=None, chunk_size=1024, **kwargs):
To override KBs for journal names etc., use ``override_kbs_files``:
>>> extract_references_from_url(path, override_kbs_files={'journals': 'my/path/to.kb'})
>>> extract_references_from_url(path,
override_kbs_files={'journals': 'my/path/to.kb'})
"""
# Get temporary filepath to download to
Expand Down Expand Up @@ -126,7 +127,8 @@ def extract_references_from_file(path,
To override KBs for journal names etc., use ``override_kbs_files``:
>>> extract_references_from_file(path, override_kbs_files={'journals': 'my/path/to.kb'})
>>> extract_references_from_file(path,
override_kbs_files={'journals': 'my/path/to.kb'})
"""
if not os.path.isfile(path):
Expand All @@ -150,11 +152,14 @@ def extract_references_from_file(path,
extracted_texkeys_urls = extract_texkeys_and_urls_from_pdf(path)
if len(extracted_texkeys_urls) == len(parsed_refs):
parsed_refs_updated = []
for ref, ref_texkey_urls in zip(parsed_refs, extracted_texkeys_urls, strict=False):
for ref, ref_texkey_urls in zip(parsed_refs,
extracted_texkeys_urls,
strict=False):
update_reference_with_urls(ref, ref_texkey_urls.get('urls', []))
if ref.get('url'):
ref['url'] = dedupe_list(ref['url'])
parsed_refs_updated.append(dict(ref, texkey=[ref_texkey_urls['texkey']]))
parsed_refs_updated.append(dict(ref,
texkey=[ref_texkey_urls['texkey']]))

return parsed_refs_updated
return parsed_refs
Expand Down Expand Up @@ -186,7 +191,8 @@ def extract_references_from_string(source,
To override KBs for journal names etc., use ``override_kbs_files``:
>>> extract_references_from_string(path, override_kbs_files={'journals': 'my/path/to.kb'})
>>> extract_references_from_string(path,
override_kbs_files={'journals': 'my/path/to.kb'})
"""
docbody = source.split('\n')
if not is_only_references:
Expand Down
Loading

0 comments on commit e04e160

Please sign in to comment.