Skip to content

Commit 6991550

Browse files
author
Marcin Kardas
committed
Better error message for withdrawn papers
1 parent b541c40 commit 6991550

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

sota_extractor2/helpers/unpack.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class Unpack:
1212

1313
def __init__(self):
1414
self.magic = Magic(mime=True, uncompress=True)
15+
self.magic_formatted = Magic(mime=False, uncompress=True)
1516

1617
def __call__(self, source, dest):
1718
pipeline_logger(f"{Unpack.step}::call", source=source, dest=dest)
@@ -29,5 +30,8 @@ def __call__(self, source, dest):
2930
copyfileobj(src, dst)
3031
elif mime == 'application/pdf':
3132
raise UnpackError(f"No LaTeX source code available for this paper, PDF only")
33+
elif mime == 'text/plain' and 'withdrawn' in self.magic_formatted.from_file(str(source)):
34+
raise UnpackError(f"The paper has been withdrawn and there is"
35+
f" no LaTeX source code available")
3236
else:
3337
raise UnpackError(f"Cannot unpack file of type {mime}")

0 commit comments

Comments
 (0)